using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class Device_Switch : Device_Base { public bool isOpen; /// /// 操作开关事件 /// private Action actionBack; /// /// 添加开关操作回调 /// /// public void AddAction(Action actionBack) { this.actionBack= actionBack; } private void OnMouseDown() { if(isOpen) { isOpen = false; transform.localEulerAngles = new Vector3(45, 0, 0); } else { isOpen = true; transform.localEulerAngles = new Vector3(0, 0, 0); } //调用自定义事件 if (actionBack != null) { actionBack.Invoke(isOpen); } } }