Unity UGUI Button鼠标的悬停事件(利用重写unity中的button来实现)

using UnityEngine;

using System.Collections;

using UnityEngine.UI;

using UnityEngine.EventSystems;

public class LearnButton : Button 

{

    ///

    /// 配合Unity的其他方法使用,就能达到你想要的效果!这里只是抛砖引玉,大家有更好的方法欢迎跟我交流!

    ///

    ///

    ///

    protected override void DoStateTransition(SelectionState state, bool instant)

    {

        base.DoStateTransition(state, instant);

        switch (state)

        {

            case SelectionState.Disabled:

                break;

            case SelectionState.Highlighted:

                Debug.Log("鼠标移到button上!");

                break;

            case SelectionState.Normal:

                Debug.Log("鼠标离开Button!");

                break;

            case SelectionState.Pressed:

                break;

            default:

                break;

        }

    }

}

 

你可能感兴趣的:(C#)