using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class SetNodePlane : MonoBehaviour, IPointerEnterHandler,IPointerExitHandler { /// /// 用于右侧面板触发显隐 /// private Animator Ani; private Vector3 velocity = Vector3.zero; void Start () { Ani = this.transform.GetComponent(); } Vector3 ShowtargetPosition = new Vector3(-190, -495, 0); Vector3 HidetargetPosition = new Vector3(203, -495, 0); bool Enter = false; bool Hide = false; public void OnPointerEnter(PointerEventData eventData) { Hide = false; Enter = true; } public void OnPointerExit(PointerEventData eventData) { Hide = true; Enter = false; } void Update() { if (Enter) { transform.GetComponent().anchoredPosition = Vector3.SmoothDamp(transform.GetComponent().anchoredPosition, ShowtargetPosition, ref velocity, 0.1f); } if (Hide) { transform.GetComponent().anchoredPosition = Vector3.SmoothDamp(transform.GetComponent().anchoredPosition, HidetargetPosition, ref velocity, 0.1f); } //ToolbarObject父对象在移动指挥终端模式下,start里设置隐藏了,但是找不着其他地方哪里又设置成true了,所以在这里特殊处理下 if (ModeHelper.Mode == Mode.MobileCommunication) { if (transform.parent.gameObject.activeSelf) { transform.parent.gameObject.SetActive(false); } } } }