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

来源:互联网 发布:mac查exif 编辑:程序博客网 时间:2024/05/29 21:30

NGUI讨论群:333417608

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

MonoBehaviourSZUIPressedButton

using UnityEngine;using System.Collections.Generic; public class SZUIPressedButton : UIWidgetContainer{        public List<EventDelegate> onPressed = new List<EventDelegate> ();        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);        }}


原创粉丝点击