-
Notifications
You must be signed in to change notification settings - Fork 0
/
IceballButton.cs
35 lines (32 loc) · 897 Bytes
/
IceballButton.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class IceballButton : MonoBehaviour {
private int iceballs;
private Button myButton;
private Text myText;
bool hasStarted;
// Use this for initialization
void Start () {
myButton = GetComponent<Button>();
myText = GetComponentInChildren<Text>();
}
// Update is called once per frame
void Update () {
hasStarted = BallShooter.instance.hasStarted;
iceballs = BallShooter.instance.iceballs;
if (iceballs >=2){
myText.gameObject.SetActive(true);
myText.text = iceballs.ToString();
}else{
myText.gameObject.SetActive(false);
}
if (iceballs >= 1 && !hasStarted){
myButton.interactable = true;
}else if(iceballs <= 0 || hasStarted){
myButton.interactable = false;
myText.gameObject.SetActive(false);
}
}
}