using DG.Tweening; using HighlightPlus; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; /// /// ÆÕͨÃÅ /// public class Door : PermanentTriggerBase { public bool isOpen; public ZhouEnum zhouEnum; public float angele; public float duration; Dictionary dic; [SerializeField] private Vector3 initR; [SerializeField] private Vector3 nextR; protected override void OnAwake() { base.OnAwake(); GetEndAngle(); } protected override void OnMDown() { base.OnMDown(); isOpen = !isOpen; transform.DOLocalRotate(dic[isOpen], duration); } protected override void OnMEnter() { base.OnMEnter(); _highlight.SetHighlighted(true); } protected override void OnMExit() { _highlight.SetHighlighted(false); base.OnMExit(); } private void GetEndAngle() { initR = transform.localEulerAngles; transform.Rotate(new Vector3(zhouEnum == ZhouEnum.X ? 1 : 0, zhouEnum == ZhouEnum.Y ? 1 : 0, zhouEnum == ZhouEnum.Z ? 1 : 0), angele, Space.Self); nextR = transform.localEulerAngles; transform.localEulerAngles = initR; dic = new Dictionary(); dic.Add(isOpen, initR); dic.Add(!isOpen, nextR); } } public enum ZhouEnum { X, Y, Z }