45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ModelLocation:MonoBehaviour
|
|
{
|
|
public static ModelLocation instance;
|
|
public string[] names;
|
|
public Transform[] trans;
|
|
public GameObject[] lights;//所有灯光
|
|
public bool lightState = false;
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
}
|
|
private void Start()
|
|
{
|
|
lightState = false;
|
|
for (int i = 0; i < lights.Length; i++)
|
|
{
|
|
lights[i].SetActive(false);
|
|
}
|
|
}
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.K))
|
|
{
|
|
StartCoroutine(SetLightState(true));
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.L))
|
|
{
|
|
StartCoroutine(SetLightState(false));
|
|
}
|
|
}
|
|
public IEnumerator SetLightState(bool isOpen)
|
|
{
|
|
WaitForSeconds waitForSeconds = new WaitForSeconds(0.1f);
|
|
for (int i = 0; i < lights.Length; i++)
|
|
{
|
|
yield return waitForSeconds;
|
|
lights[i].SetActive(isOpen);
|
|
}
|
|
}
|
|
}
|