Untitled
unknown
plain_text
a year ago
1.9 kB
12
Indexable
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class ButtonColorHandler : MonoBehaviour, ISelectHandler, IDeselectHandler {
[SerializeField] private Button thisButton;
[SerializeField] private GameObject thisGO;
[SerializeField] private Button newButton;
[SerializeField] private float buttonAmount;
[Header("BoxColorReferences")]
[SerializeField] public GameObject NumBoxOne;
[SerializeField] public GameObject NumBoxTwo;
[SerializeField] public GameObject PointLightOne;
[SerializeField] public GameObject PointLightTwo;
[SerializeField] public GameObject PointLightThree;
[SerializeField] public GameObject OtherLights;
[SerializeField] public GameObject OtherBox;
private void Update() {
if (KhronsHolder.KhronsAmount == buttonAmount) {
thisButton.interactable = false;
} else {
thisButton.interactable = true;
}
}
public void OnSelect(BaseEventData eventData) {
// Debug.Log(this.gameObject.name + " was selected");
NumBoxOne.SetActive(true);
NumBoxTwo.SetActive(true);
PointLightOne.SetActive(true);
PointLightTwo.SetActive(true);
PointLightThree.SetActive(true);
OtherLights.SetActive(true);
OtherBox.SetActive(true);
Debug.Log("I was triggered");
}
public void OnDeselect(BaseEventData data) {
// Debug.Log("Deselected");
NumBoxOne.SetActive(false);
NumBoxTwo.SetActive(false);
PointLightOne.SetActive(false);
PointLightTwo.SetActive(false);
PointLightThree.SetActive(false);
if (thisButton.interactable == false) {
Debug.Log(" I was turned off");
}
}
}
Editor is loading...
Leave a Comment