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);
}
}