35 lines
897 B
C#
35 lines
897 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CabinetDevice : MonoBehaviour
|
|
{
|
|
public Vector3 open_angle;
|
|
public List<Transform> door_list = new List<Transform>();
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
if(transform.GetChild(i).name.Contains("Object")|| transform.GetChild(i).name.Contains("object"))
|
|
{
|
|
door_list.Add(transform.GetChild(i));
|
|
}
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
UpdateDoorState(open);
|
|
}
|
|
public bool open;
|
|
/// <summary>
|
|
/// ¸üйñÃÅ״̬
|
|
/// </summary>
|
|
public void UpdateDoorState(bool open)
|
|
{
|
|
door_list.ForEach(t => { t.localEulerAngles = open ? open_angle : Vector3.zero; });
|
|
}
|
|
}
|