1
0
mirror of https://github.com/xiaopeng12138/MaiDXR.git synced 2025-02-26 06:28:04 +01:00
MaiDXR/Assets/Scripts/ButtonLock.cs

35 lines
776 B
C#
Raw Normal View History

2022-08-04 23:38:59 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ButtonLock : MonoBehaviour
{
public List<GameObject> buttons;
bool isLocked = false;
Material material;
void Start()
{
material = GetComponent<Renderer>().material;
material.color = Color.green;
Debug.Log("ButtonLock Start");
}
// Update is called once per frame
void OnTriggerEnter(Collider other)
{
for (int i = 0; i < buttons.Count; i++)
{
buttons[i].SetActive(!buttons[i].activeSelf);
}
isLocked = !isLocked;
if (isLocked)
{
material.color = Color.red;
}
else
{
material.color = Color.green;
}
}
}