Added coliders to buttons, Buttons are clickable
This commit is contained in:
15
Assets/Scripts/ButtonScript.cs
Normal file
15
Assets/Scripts/ButtonScript.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ButtonScript : MonoBehaviour
|
||||
{
|
||||
public int buttonIndex;
|
||||
public ButtonsMinigame game;
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
game.OnButtonClicked(buttonIndex);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
2
Assets/Scripts/ButtonScript.cs.meta
Normal file
2
Assets/Scripts/ButtonScript.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ddbb77eddbb18d4aa26a61ef9cdadb1
|
||||
@@ -8,9 +8,10 @@ public class ButtonsMinigame : MonoBehaviour
|
||||
public int round = 1;
|
||||
public float glowDuration = 0.4f;
|
||||
public float gapBetween = 0.15f;
|
||||
private int playerStep = 0;
|
||||
private List<int> sequence = new List<int>();
|
||||
|
||||
void Generatesequence()
|
||||
void GenerateSequence()
|
||||
{
|
||||
sequence.Clear();
|
||||
for (int i = 0; i < round; i++)
|
||||
@@ -20,7 +21,7 @@ public class ButtonsMinigame : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Playsequence()
|
||||
IEnumerator PlaySequence()
|
||||
{
|
||||
for (int i = 0; i < sequence.Count; i++)
|
||||
{
|
||||
@@ -34,8 +35,13 @@ public class ButtonsMinigame : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
Generatesequence();
|
||||
StartCoroutine(Playsequence());
|
||||
GenerateSequence();
|
||||
StartCoroutine(PlaySequence());
|
||||
}
|
||||
|
||||
public void OnButtonClicked(int buttonIndex)
|
||||
{
|
||||
Debug.Log("Clicked : " + buttonIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user