質問編集履歴
1
ソースコード変更いたしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -65,4 +65,70 @@
|
|
65
65
|
--------------------------------------------------------------------
|
66
66
|
|
67
67
|
どなたかご教授いただけますと大変助かります。
|
68
|
-
ご確認の程よろしくお願い致します。
|
68
|
+
ご確認の程よろしくお願い致します。
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
※補足
|
74
|
+
2つのコードをつなぎ合わせたものです。
|
75
|
+
エラーはなく、クリックしても音声もならず、シーン遷移も行いません。
|
76
|
+
ご確認の程よろしくお願い致します。
|
77
|
+
|
78
|
+
------------------------------------------------------
|
79
|
+
|
80
|
+
'''
|
81
|
+
//シーン切り替え
|
82
|
+
using UnityEngine;
|
83
|
+
using System.Collections;
|
84
|
+
using UnityEngine.SceneManagement;// ←new!
|
85
|
+
|
86
|
+
|
87
|
+
//---------------------------------------------------
|
88
|
+
//===================================================
|
89
|
+
public class test : MonoBehaviour {
|
90
|
+
GameObject obj;
|
91
|
+
int counter = 0;
|
92
|
+
private readonly string NEXT_SCENE_NAME = "1";
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
// AudioSourceはInspectorでセット.
|
97
|
+
// かつAudioClipもInspectorでAudioSourceにアタッチ済みであること前提.
|
98
|
+
[SerializeField] private AudioSource audio = null;
|
99
|
+
[SerializeField ] private AudioClip clip = null;
|
100
|
+
|
101
|
+
|
102
|
+
//---------------------------------------------------
|
103
|
+
|
104
|
+
void Update () {
|
105
|
+
if (Input.GetMouseButtonDown (0)) {
|
106
|
+
Vector3 pos = Input.mousePosition;
|
107
|
+
Ray ray = Camera.main.ScreenPointToRay (pos);
|
108
|
+
RaycastHit hit;
|
109
|
+
if (Physics.Raycast (ray, out hit, 100f)) {
|
110
|
+
obj = hit.collider.gameObject;
|
111
|
+
counter = 100;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
//---------------------------------------------------
|
117
|
+
// コルーチンで次のシーンへ遷移.
|
118
|
+
private IEnumerator changeScene(){
|
119
|
+
|
120
|
+
this.audio.PlayOneShot( this.clip );
|
121
|
+
//this.audio.PlayOneShot( this.audio.clip );
|
122
|
+
while ( this.audio.isPlaying ){
|
123
|
+
yield return new WaitForSeconds( 1.0f );
|
124
|
+
}
|
125
|
+
SceneManager.LoadScene( this.NEXT_SCENE_NAME );
|
126
|
+
|
127
|
+
yield return null;
|
128
|
+
}
|
129
|
+
|
130
|
+
}
|
131
|
+
|
132
|
+
'''
|
133
|
+
|
134
|
+
-------------------------------------------------------------------------
|