protected IfEvent UnityEvent2IfEvent(UnityEngine.Events.UnityEvent e)
    {
        object target = e.GetPersistentTarget(0);
        Type   t      = target.GetType();

        System.Reflection.MethodInfo mi = t.GetMethod(e.GetPersistentMethodName(0));
        IfEvent ie = () => {
            object o = mi.Invoke(target, new object[] {});
            return((bool)o);
        };

        return(ie);
    }
Ejemplo n.º 2
0
        public static void RenderConnection(MonoBehaviour caster, UnityEvent ev)
        {
            Color gizmosColor = Gizmos.color;
            for (int i = 0, len = ev.GetPersistentEventCount(); i < len; i++)
            {
                Event target = ev.GetPersistentTarget(i) as Event;
                if (target)
                {
                    string method = ev.GetPersistentMethodName(i);
                    if (method == "StartEvent")
                        Gizmos.color = Color.green;
                    else if (method == "set_enabled")
                        Gizmos.color = Color.blue;
                    else
                        return;

                    Gizmos.DrawLine(caster.transform.position, target.transform.position);
                }
            }
            Gizmos.color = gizmosColor;
        }