2022-08-12 02:20:00 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.XR.Interaction.Toolkit;
|
|
|
|
|
|
|
|
public class Locker : MonoBehaviour
|
|
|
|
{
|
|
|
|
public float Delay = 2.0f;
|
|
|
|
float targetTime;
|
|
|
|
public List<GameObject> buttons;
|
|
|
|
public GameObject LocalMotion;
|
2022-08-16 23:22:52 +02:00
|
|
|
public List<GameObject> RayObjects;
|
2022-08-12 02:20:00 +02:00
|
|
|
bool isLocked = false;
|
|
|
|
Material material;
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
targetTime = Delay;
|
|
|
|
material = GetComponent<Renderer>().material;
|
|
|
|
material.color = Color.green;
|
|
|
|
Debug.Log("ButtonLock Start");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
2022-08-27 00:04:14 +02:00
|
|
|
public void ToggleLocker()
|
2022-08-12 02:20:00 +02:00
|
|
|
{
|
2022-08-16 23:22:52 +02:00
|
|
|
ToggleButtons();
|
|
|
|
ToggleLocalmotion();
|
2022-08-26 22:06:45 +02:00
|
|
|
//ToggleRay();
|
2022-08-12 02:20:00 +02:00
|
|
|
isLocked = !isLocked;
|
|
|
|
if (isLocked)
|
|
|
|
material.color = Color.red;
|
|
|
|
else
|
|
|
|
material.color = Color.green;
|
|
|
|
}
|
|
|
|
void OnTriggerStay(Collider other)
|
|
|
|
{
|
|
|
|
targetTime -= Time.deltaTime;
|
|
|
|
if (targetTime <= 0.0f)
|
|
|
|
{
|
|
|
|
ToggleLocker();
|
|
|
|
targetTime = Delay;
|
|
|
|
}
|
|
|
|
}
|
2022-08-16 23:22:52 +02:00
|
|
|
void ToggleLocalmotion()
|
|
|
|
{
|
|
|
|
LocalMotion.GetComponent<ContinuousMoveProviderBase>().enabled = !LocalMotion.GetComponent<ContinuousMoveProviderBase>().enabled;
|
|
|
|
LocalMotion.GetComponent<ContinuousTurnProviderBase>().enabled = !LocalMotion.GetComponent<ContinuousTurnProviderBase>().enabled;
|
|
|
|
}
|
|
|
|
void ToggleButtons()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < buttons.Count; i++)
|
|
|
|
buttons[i].SetActive(!buttons[i].activeSelf);
|
|
|
|
}
|
|
|
|
void ToggleRay()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < RayObjects.Count; i++)
|
|
|
|
RayObjects[i].GetComponent<RayManager>().RaySwitch= !RayObjects[i].GetComponent<RayManager>().RaySwitch;
|
|
|
|
}
|
2022-08-12 02:20:00 +02:00
|
|
|
}
|