-
Notifications
You must be signed in to change notification settings - Fork 0
/
StartButton.cs
44 lines (38 loc) · 1.28 KB
/
StartButton.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StartButton : MonoBehaviour
{
private RectTransform rect;
private ParticleSystem part;
private Transform trans;
private Player1Controller button;
private bool isPressed;
private bool playing;
public GameObject xboxController;
// Use this for initialization
void Start()
{
rect = GetComponent<RectTransform>();
part = GetComponent<ParticleSystem>();
trans = rect.transform;
button = xboxController.GetComponent<Player1Controller>();
}
// Update is called once per frame
void Update()
{
if (button.startButton == true) //if A button goes down
{
if (part.isPlaying == false) //and if particle system is not playing
{
trans.localPosition = new Vector3(Random.Range(-70, -1000), Random.Range(-500, 500), Random.Range(200, 300)); //pick a random location within the button square and move to it
part.Play(true); //play the animation
Component[] children = GetComponentsInChildren<ParticleSystem>(); //create an array of all the children of the particle system
foreach (ParticleSystem childParticleSystem in children) //for each child
{
childParticleSystem.Play(true); //play the partcle system
}
}
}
}
}