Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonScript.cs
More file actions
Latest commit
49 lines (41 loc) · 1.15 KB
/
Copy pathButtonScript.cs
File metadata and controls
49 lines (41 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
usingSystem.Collections;
usingSystem.Collections.Generic;
usingUnityEngine;
publicclassButtonScript:MonoBehaviour
{
publicstaticboolpressing;
publicMeshRendererbuttonMesh;
publicLightbuttonLight;
publicColorPressedColor;
publicAudioSourcePressSound;
privateColorinitColor;
privateColorinitLightColor;
voidStart()
{
initColor=GetComponent<MeshRenderer>().material.color;
initLightColor=buttonLight.color;
}
voidUpdate()
{
if(Input.GetKeyDown(KeyCode.U))
{
pressing=true;
buttonMesh.material.color=PressedColor;
buttonLight.color=PressedColor;
PressSound.Play();
}
}
voidOnTriggerEnter(Colliderother)
{
pressing=true;
buttonMesh.material.color=PressedColor;
buttonLight.color=PressedColor;
PressSound.Play();
}
voidOnTriggerExit(Colliderother)
{
pressing=false;
buttonMesh.material.color=initColor;
buttonLight.color=initLightColor;
}
}