using UnityEngine; using System.Collections; using Assets.Code.myclass; using UnityEngine.UI; using DG.Tweening; using UnityEngine.EventSystems; public class ButtonEventTriggerListener : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
//单例模式 static ButtonEventTriggerListener buttonEvent_this; public static ButtonEventTriggerListener Instance() { if (buttonEvent_this == null) { buttonEvent_this = new ButtonEventTriggerListener(); } return buttonEvent_this; }
private float origiValue; private float endValue = 205; private GameObject btnBcak; private string mainPanelPath = "mainControllerPanel(Clone)/back/menuPanel/"; public void Start() { btnBcak = GameObject.Find(mainPanelPath + "RoamBack").gameObject; origiValue = btnBcak.transform.position.x; } public void OnPointerEnter(PointerEventData eventData) { Debug.LogError("进入"); btnBcak.transform.DOLocalMoveX(endValue, 0.5f); } public void OnPointerExit(PointerEventData eventData) { Debug.LogError("退出"); btnBcak.transform.DOLocalMoveX(origiValue, 0.5f); } }