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; 
        } 
    } 
}
—— 完 ——
相关推荐
评论

立 为 非 似

中 谁 昨 此

宵 风 夜 星

。 露 , 辰

文章点击榜

细 无 轻 自

如 边 似 在

愁 丝 梦 飞

。 雨 , 花