【Unity3D】【NGUI】处理Button的按下状态?

NGUI讨论群:333417608

提供一个脚本,会不会用就看各位的造化了。

MonoBehaviourSZUIPressedButton

using UnityEngine;
using System.Collections.Generic;
 
public class SZUIPressedButton : UIWidgetContainer
{
        public List onPressed = new List ();
        private bool pressed = false;
         
        void Update ()
        {
                if (pressed)
                {
                        EventDelegate.Execute(onPressed);
                }
        }
         
        public void OnPress (bool isPressed)
        {
                pressed = isPressed;
        }
         
        void OnDisable()
        {
                pressed = false;
        }
}

编辑脚本:SZUIPressedButtonEditor

using UnityEngine;
using UnityEditor;
 
[CustomEditor(typeof(SZUIPressedButton))]
public class SZUIPressedButtonEditor : Editor
{
        public override void OnInspectorGUI ()
        {
                SZUIPressedButton pb = target as SZUIPressedButton;
                NGUIEditorTools.DrawEvents("On Pressed", pb, pb.onPressed);
        }
}


你可能感兴趣的:(NGUI,Unity3D)