control panel stuff
all about the control panel - made a text object for each button to replace the single text box covering all buttons - some visual changes - added a button that locks all control panel buttons
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ControlLocker : MonoBehaviour
|
||||
{
|
||||
private int colliderCount = 0;
|
||||
private bool isLocked = false;
|
||||
|
||||
[SerializeField]
|
||||
private RawImage statusImg;
|
||||
[SerializeField]
|
||||
private Texture lockImg;
|
||||
[SerializeField]
|
||||
private Texture unlockImg;
|
||||
[SerializeField]
|
||||
private List<ControlPanel> cpanButtons;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
statusImg.texture = unlockImg;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider _)
|
||||
{
|
||||
Debug.Log("Lock btn pressed.");
|
||||
colliderCount++;
|
||||
if (colliderCount == 1)
|
||||
{
|
||||
// set state var
|
||||
isLocked = !isLocked;
|
||||
|
||||
// set img
|
||||
statusImg.texture = isLocked ? lockImg : unlockImg;
|
||||
|
||||
// set buttons' state
|
||||
foreach (var btn in cpanButtons)
|
||||
{
|
||||
btn.GetComponent<Collider>().enabled = !isLocked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider _)
|
||||
{
|
||||
Debug.Log("Lock btn unpressed.");
|
||||
colliderCount--;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user