zoukankan      html  css  js  c++  java
  • unity中实现监听鼠标的进入和退出某一个UI按钮

    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); } }
  • 相关阅读:
    Git 最全命令使用
    git 配置(实用)
    用Redis进行实时数据排名
    最长上升子序列
    KMP算法
    计算星期几【基姆拉尔森公式】
    集合划分(贝尔数)
    合数分解(质因数分解)
    乘法逆元
    扩展欧几里得算法
  • 原文地址:https://www.cnblogs.com/Study088/p/7735203.html
Copyright © 2011-2022 走看看