-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAButton.cs
60 lines (48 loc) · 1.59 KB
/
AButton.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AButton : MonoBehaviour
{
private RectTransform rect;
private ParticleSystem part;
private Transform trans;
private Player1Controller button;
private bool isPressed;
private bool playing;
private ParticleSystem.MainModule settings;
private Color startColor;
public GameObject xboxController;
// Use this for initialization
void Start()
{
rect = GetComponent<RectTransform>();
part = GetComponent<ParticleSystem>();
trans = rect.transform;
button = xboxController.GetComponent<Player1Controller>();
settings = GetComponent<ParticleSystem>().main;
}
// Update is called once per frame
void Update()
{
if (button.aButton == 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
}
}
}
}
}
/*
* ParticleSystem.MainModule settings = GetComponent<ParticleSystem>().main;
settings.startColor = new ParticleSystem.MinMaxGradient( yourColor );
*
*
*
*/