質問編集履歴
10
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
9
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
audioSource.clip=sound;
|
48
48
|
|
49
|
-
AudioSource.
|
49
|
+
AudioSource.Stop();
|
50
50
|
|
51
51
|
|
52
52
|
|
8
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
{
|
32
32
|
|
33
|
-
if (collision.gameObject.name==
|
33
|
+
if (collision.gameObject.name==“Cube1”){
|
34
34
|
|
35
35
|
audioSource.clip=sound;
|
36
36
|
|
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
private void OnCollisionExit(Collision collision){
|
42
42
|
|
43
|
-
if (collision.gameObject.name==
|
43
|
+
if (collision.gameObject.name==“Cube1”){
|
44
44
|
|
45
45
|
|
46
46
|
|
7
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,32 +1,58 @@
|
|
1
|
-
特定のオブジェクト(Cube1)に触れている時だけ音を鳴らしたいのですが、そのオブジェクトを離れても音がなり止みません。
|
1
|
+
特定のオブジェクト(Cube1)に触れている時だけ音を鳴らしたいのですが、そのオブジェクトを離れても音がなり止みません。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```using UnityEngine;
|
2
6
|
|
3
7
|
using System.Collections;
|
4
8
|
|
5
|
-
public class Sound : MonoBehaviour{
|
6
9
|
|
7
|
-
public AudioClip sound;
|
8
10
|
|
9
|
-
p
|
11
|
+
public class Sound : MonoBehavior
|
10
12
|
|
11
|
-
void Start()
|
12
13
|
|
13
|
-
{
|
14
14
|
|
15
|
-
|
15
|
+
public AudioClip sound;
|
16
16
|
|
17
|
-
private
|
17
|
+
private AudioSource audioSourc
|
18
18
|
|
19
|
-
if (collision.gameObject.name == "Cube1") { audioSource.clip = sound;
audioSource.Play();
|
20
19
|
|
21
|
-
}
|
22
20
|
|
23
|
-
|
21
|
+
void Start()
|
24
22
|
|
25
|
-
|
23
|
+
{
|
26
24
|
|
27
|
-
|
25
|
+
|
28
26
|
|
29
|
-
}
|
27
|
+
}
|
28
|
+
|
29
|
+
private void OnCollisionEnter (Collision collision)
|
30
|
+
|
31
|
+
{
|
32
|
+
|
33
|
+
if (collision.gameObject.name==''Cube1''){
|
34
|
+
|
35
|
+
audioSource.clip=sound;
|
36
|
+
|
37
|
+
AudioSource.Play();
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
private void OnCollisionExit(Collision collision){
|
42
|
+
|
43
|
+
if (collision.gameObject.name==''Cube1''){
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
audioSource.clip=sound;
|
48
|
+
|
49
|
+
AudioSource.Play();
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
30
56
|
|
31
57
|
}
|
32
58
|
|
6
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
特定のオブジェクト(Cube1)に触れている時だけ音を鳴らしたいのですが、そのオブジェクトを離れても音がなり止みません。```
|
1
|
+
特定のオブジェクト(Cube1)に触れている時だけ音を鳴らしたいのですが、そのオブジェクトを離れても音がなり止みません。```using UnityEngine;
|
2
2
|
|
3
3
|
using System.Collections;
|
4
4
|
|
5
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
特定のオブジェクト(Cube1)に触れている時だけ音を鳴らしたいのですが、そのオブジェクトを離れても音がなり止みません。````````````using UnityEngine;
|
1
|
+
特定のオブジェクト(Cube1)に触れている時だけ音を鳴らしたいのですが、そのオブジェクトを離れても音がなり止みません。````````````using UnityEngine;
|
2
|
-
|
3
|
-
`````````using UnityEngine;
|
4
2
|
|
5
3
|
using System.Collections;
|
6
4
|
|
@@ -32,9 +30,7 @@
|
|
32
30
|
|
33
31
|
}
|
34
32
|
|
35
|
-
コード
|
36
33
|
|
37
|
-
```
|
38
34
|
|
39
35
|
コード
|
40
36
|
|
4
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,9 +1,41 @@
|
|
1
1
|
特定のオブジェクト(Cube1)に触れている時だけ音を鳴らしたいのですが、そのオブジェクトを離れても音がなり止みません。
|
2
2
|
|
3
|
+
`````````using UnityEngine;
|
3
4
|
|
5
|
+
using System.Collections;
|
4
6
|
|
5
|
-
|
7
|
+
|
8
|
+
|
9
|
+
public AudioClip sound;
|
10
|
+
|
11
|
+
private AudioSource audioSource;
|
12
|
+
|
13
|
+
void Start()
|
14
|
+
|
15
|
+
{
|
16
|
+
|
17
|
+
audioSource = GetComponent<AudioSource>();
}
|
18
|
+
|
19
|
+
private void OnCollisionEnter(Collision collision)
{
|
20
|
+
|
21
|
+
if (collision.gameObject.name == "Cube1") { audioSource.clip = sound;
audioSource.Play();
|
22
|
+
|
23
|
+
}
|
24
|
+
|
25
|
+
private void OnCollisionExit(Collision collision)
{
|
26
|
+
|
27
|
+
if (collision.gameObject.name == "Cube1"){
audioSource.clip = sound;
audioSource.Stop();
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
}
|
32
|
+
|
33
|
+
}
|
6
34
|
|
7
35
|
コード
|
8
36
|
|
9
37
|
```
|
38
|
+
|
39
|
+
コード
|
40
|
+
|
41
|
+
```
|
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
特定のオブジェクト(Cube1)に触れている時だけ音を鳴らしたいのですが、そのオブジェクトを離れても音がなり止みません。
|
2
2
|
|
3
|
-
```using UnityEngine;
using System.Collections;
public class Sound : MonoBehaviour{
public AudioClip sound;
private AudioSource audioSource;
void Start()
{
audioSource = GetComponent<AudioSource>();
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Cube1") {
audioSource.clip = sound;
audioSource.Play();
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.name == "Cube1"){
audioSource.clip = sound;
|
4
|
-
|
5
|
-
audioSource.stop();
|
6
|
-
|
7
|
-
}
}
}
|
8
3
|
|
9
4
|
|
5
|
+
``````using UnityEngine;
using System.Collections;
public class Sound : MonoBehaviour{
public AudioClip sound;
private AudioSource audioSource;
void Start()
{
audioSource = GetComponent<AudioSource>();
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Cube ) audioSource.clip = sound;
audioSource.Play();
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.name == "Cube1"){
audioSource.clip = sound;
audioSource.Stop();
}
}
}
|
10
6
|
|
11
7
|
コード
|
12
8
|
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
特定のオブジェクト(Cube1)に触れている時だけ音を鳴らしたいのですが、そのオブジェクトを離れても音がなり止みません。
|
2
2
|
|
3
|
-
```
|
3
|
+
```using UnityEngine;
using System.Collections;
public class Sound : MonoBehaviour{
public AudioClip sound;
private AudioSource audioSource;
void Start()
{
audioSource = GetComponent<AudioSource>();
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Cube1") {
audioSource.clip = sound;
audioSource.Play();
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.name == "Cube1"){
audioSource.clip = sound;
|
4
4
|
|
5
5
|
audioSource.stop();
|
6
6
|
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
特定のオブジェクト(Cube1)に触れている時だけ音を鳴らしたいのですが、そのオブジェクトを離れても音がなり止みません。
|
2
2
|
|
3
|
+
`````using UnityEngine;
using System.Collections;
public class Sound : MonoBehaviour{
public AudioClip sound;
private AudioSource audioSource;
void Start()
{
audioSource = GetComponent<AudioSource>();
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Cube1") {
audioSource.clip = sound;
audioSource.Play();
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.name == "Cube1"){
audioSource.clip = sound;
|
4
|
+
|
5
|
+
audioSource.stop();
|
6
|
+
|
7
|
+
}
}
}
|
3
8
|
|
4
9
|
|
5
|
-
``using UnityEngine;
using System.Collections;
public class Sound : MonoBehaviour{
public AudioClip sound;
private AudioSource audioSource;
void Start()
{
audioSource = GetComponent<AudioSource>();
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Cube1") {
audioSource.clip = sound;
audioSource.Play();
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.name == "Cube1"){
audioSource.clip = sound;
audioSource.Stop();
}
}
}
|
6
10
|
|
7
11
|
コード
|
8
12
|
|