示例#1
0
    /// <summary>
    /// returns all registered events and actions, along with
    /// their target objects as a formatted string. TIP: call
    /// this from a 'Start' method or from a bound key, since by
    /// then all objects should have called in to the handler.
    /// do not call it from 'Awake'.
    /// </summary>
    public static string Dump(vp_EventHandler handler, string [] eventTypes)
    {
        string s = "";        // "--- EVENT DUMP ---\n\n";

        foreach (string type in eventTypes)
        {
            switch (type)
            {
            case "vp_Message":
                s += DumpEventsOfType("vp_Message", (eventTypes.Length > 1 ? "MESSAGES:\n\n" : ""), handler);
                break;

            case "vp_Attempt":
                s += DumpEventsOfType("vp_Attempt", (eventTypes.Length > 1 ? "ATTEMPTS:\n\n" : ""), handler);
                break;

            case "vp_Value":
                s += DumpEventsOfType("vp_Value", (eventTypes.Length > 1 ? "VALUES:\n\n" : ""), handler);
                break;

            case "vp_Activity":
                s += DumpEventsOfType("vp_Activity", (eventTypes.Length > 1 ? "ACTIVITIES:\n\n" : ""), handler);
                break;
            }
        }
        return(s);
    }
示例#2
0
	/// <summary>
	/// returns all registered events and actions, along with
	/// their target objects as a formatted string. TIP: call
	/// this from a 'Start' method or from a bound key, since by
	/// then all objects should have called in to the handler.
	/// do not call it from 'Awake'.
	/// </summary>
	public static string Dump(vp_EventHandler handler, string []eventTypes)
	{

		string s = "";// "--- EVENT DUMP ---\n\n";

		foreach (string type in eventTypes)
		{
			switch (type)
			{
				case "vp_Message":
					s += DumpEventsOfType("vp_Message", (eventTypes.Length > 1 ? "MESSAGES:\n\n" : ""), handler);
					break;
				case "vp_Attempt":
					s += DumpEventsOfType("vp_Attempt", (eventTypes.Length > 1 ? "ATTEMPTS:\n\n" : ""), handler);
					break;
				case "vp_Value":
					s += DumpEventsOfType("vp_Value", (eventTypes.Length > 1 ? "VALUES:\n\n" : ""), handler);
					break;
				case "vp_Activity":
					s += DumpEventsOfType("vp_Activity", (eventTypes.Length > 1 ? "ACTIVITIES:\n\n" : ""), handler);
					break;
			}
		}
		return s;

	}
示例#3
0
    public static string Dump(vp_EventHandler handler, string[] eventTypes)
    {
        string text = string.Empty;

        for (int i = 0; i < eventTypes.Length; i++)
        {
            string text2 = eventTypes[i];
            string text3 = text2;
            switch (text3)
            {
            case "vp_Message":
                text += vp_EventDump.DumpEventsOfType("vp_Message", (eventTypes.Length <= 1) ? string.Empty : "MESSAGES:\n\n", handler);
                break;

            case "vp_Attempt":
                text += vp_EventDump.DumpEventsOfType("vp_Attempt", (eventTypes.Length <= 1) ? string.Empty : "ATTEMPTS:\n\n", handler);
                break;

            case "vp_Value":
                text += vp_EventDump.DumpEventsOfType("vp_Value", (eventTypes.Length <= 1) ? string.Empty : "VALUES:\n\n", handler);
                break;

            case "vp_Activity":
                text += vp_EventDump.DumpEventsOfType("vp_Activity", (eventTypes.Length <= 1) ? string.Empty : "ACTIVITIES:\n\n", handler);
                break;
            }
        }
        return(text);
    }
示例#4
0
    /// <summary>
    /// in 'Awake' we do things that need to be run once at the
    /// very beginning. NOTE: 1) this method must be run using
    /// 'base.Awake();' on the first line of the 'Awake' method
    /// in any derived class. 2) keep in mind that as of Unity 4,
    /// gameobject hierarchy can not be altered in 'Awake'
    /// </summary>
    protected virtual void Awake()
    {
        EventHandler = (vp_EventHandler)Transform.root.GetComponentInChildren(typeof(vp_EventHandler));

        CacheChildren();
        CacheSiblings();
        CacheFamily();
        CacheRenderers();
        CacheAudioSources();

        m_StateManager = new vp_StateManager(this, States);
        StateManager.SetState("Default", enabled);
    }
示例#5
0
    /// <summary>
    ///
    /// </summary>
    private static string DumpEventsOfType(string type, string caption, vp_EventHandler handler)
    {
        string s = caption.ToUpper();

        foreach (FieldInfo f in handler.GetType().GetFields((BindingFlags.Public | BindingFlags.NonPublic |
                                                             BindingFlags.Instance | BindingFlags.DeclaredOnly)))
        {
            string listeners = null;

            switch (type)
            {
            case "vp_Message":
                if (f.FieldType.ToString().Contains("vp_Message"))
                {
                    vp_Message e = (vp_Message)f.GetValue(handler);
                    listeners = DumpEventListeners(e, new string[] { "Send" });
                }
                break;

            case "vp_Attempt":
                if (f.FieldType.ToString().Contains("vp_Attempt"))
                {
                    vp_Event e = (vp_Event)f.GetValue(handler);
                    listeners = DumpEventListeners(e, new string[] { "Try" });
                }
                break;

            case "vp_Value":
                if (f.FieldType.ToString().Contains("vp_Value"))
                {
                    vp_Event e = (vp_Event)f.GetValue(handler);
                    listeners = DumpEventListeners(e, new string[] { "Get", "Set" });
                }
                break;

            case "vp_Activity":
                if (f.FieldType.ToString().Contains("vp_Activity"))
                {
                    vp_Event e = (vp_Event)f.GetValue(handler);
                    listeners = DumpEventListeners(e, new string[] { "StartConditions", "StopConditions", "StartCallbacks", "StopCallbacks" });
                }
                break;
            }
            if (!string.IsNullOrEmpty(listeners))
            {
                s += "\t\t" + f.Name + "\n" + listeners + "\n";
            }
        }
        return(s);
    }
    /// <summary>
    ///
    /// </summary>
    public static void Create(vp_EventHandler eventHandler)
    {
        vp_EventDumpWindow window = (vp_EventDumpWindow)EditorWindow.GetWindow(typeof(vp_EventDumpWindow));

        m_EventHandler = eventHandler;

        window.titleContent.text = "Event Dump";

        window.position = new Rect(
            0,
            100,
            600,
            Screen.currentResolution.height - 150);
        window.Show();
    }
示例#7
0
 protected virtual void Awake()
 {
     this.m_Transform  = base.transform;
     this.m_Parent     = base.transform.parent;
     this.m_Root       = base.transform.root;
     this.m_Audio      = base.GetComponent <AudioSource>();
     this.EventHandler = (vp_EventHandler)this.m_Transform.root.GetComponentInChildren(typeof(vp_EventHandler));
     this.CacheChildren();
     this.CacheSiblings();
     this.CacheFamily();
     this.CacheRenderers();
     this.CacheAudioSources();
     this.m_StateManager = new vp_StateManager(this, this.States);
     this.StateManager.SetState("Default", base.enabled);
 }
	/// <summary>
	/// 
	/// </summary>
	public static void Create(vp_EventHandler eventHandler)
	{

		vp_EventDumpWindow window = (vp_EventDumpWindow)EditorWindow.GetWindow(typeof(vp_EventDumpWindow));

		m_EventHandler = eventHandler;

		window.titleContent.text = "Event Dump";

		window.position = new Rect(
			0,
			100,
			600,
			Screen.currentResolution.height - 150);
		window.Show();

	}
示例#9
0
	/// <summary>
	/// 
	/// </summary>
	private static string DumpEventsOfType(string type, string caption, vp_EventHandler handler)
	{

		string s = caption.ToUpper();
		foreach (FieldInfo f in handler.GetFields())
		{
			string listeners = null;

			switch(type)
			{
				case "vp_Message":
					if (f.FieldType.ToString().Contains("vp_Message"))
					{
						vp_Message e = (vp_Message)f.GetValue(handler);
						listeners = DumpEventListeners(e, new string[] { "Send" });
					}
					break;
				case "vp_Attempt":
					if (f.FieldType.ToString().Contains("vp_Attempt"))
					{
						vp_Event e = (vp_Event)f.GetValue(handler);
						listeners = DumpEventListeners(e, new string[] { "Try" });
					}
					break;
				case "vp_Value":
					if(f.FieldType.ToString().Contains("vp_Value"))
					{
						vp_Event e = (vp_Event)f.GetValue(handler);
						listeners = DumpEventListeners(e, new string[] { "Get", "Set" });
					}
					break;
				case "vp_Activity":
					if (f.FieldType.ToString().Contains("vp_Activity"))
					{
						vp_Event e = (vp_Event)f.GetValue(handler);
						listeners = DumpEventListeners(e, new string[] { "StartConditions", "StopConditions", "StartCallbacks", "StopCallbacks", "FailStartCallbacks", "FailStopCallbacks"	});
					}
					break;
			}
			if (!string.IsNullOrEmpty(listeners))
				s += "\t\t" + f.Name + "\n" + listeners + "\n";
		}
		return s;
	}
示例#10
0
    /// <summary>
    /// in 'Awake' we do things that need to be run once at the
    /// very beginning. NOTE: 1) this method must be run using
    /// 'base.Awake();' on the first line of the 'Awake' method
    /// in any derived class. 2) keep in mind that as of Unity 4,
    /// gameobject hierarchy can not be altered in 'Awake'
    /// </summary>
    protected virtual void Awake()
    {
        m_Transform = transform;
        m_Parent = transform.parent;
        m_Root = transform.root;
        m_Audio = audio;

        EventHandler = (vp_EventHandler)m_Transform.root.GetComponentInChildren(typeof(vp_EventHandler));

        CacheChildren();
        CacheSiblings();
        CacheFamily();
        CacheRenderers();
        CacheAudioSources();

        m_StateManager = new vp_StateManager(this, States);
        StateManager.SetState("Default", enabled);
    }
示例#11
0
 /// <summary>
 ///
 /// </summary>
 protected virtual void Awake()
 {
     EventHandler = (vp_EventHandler)FindObjectOfType(typeof(vp_EventHandler));
 }
示例#12
0
    public static void EventHandler()
    {
        vp_EventHandler EventHandler = (vp_EventHandler)GameObject.FindObjectOfType(typeof(vp_EventHandler));

        vp_EventDumpWindow.Create((vp_EventHandler)EventHandler);
    }
示例#13
0
 protected virtual void Awake()
 {
     this.EventHandler = (vp_EventHandler)UnityEngine.Object.FindObjectOfType(typeof(vp_EventHandler));
 }
示例#14
0
 /// <summary>
 /// 
 /// </summary>
 protected virtual void Awake()
 {
     EventHandler = (vp_EventHandler)FindObjectOfType(typeof(vp_EventHandler));
 }
示例#15
0
    private static string DumpEventsOfType(string type, string caption, vp_EventHandler handler)
    {
        string text = caption.ToUpper();

        FieldInfo[] fields = handler.GetType().GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
        for (int i = 0; i < fields.Length; i++)
        {
            FieldInfo fieldInfo = fields[i];
            string    text2     = null;
            switch (type)
            {
            case "vp_Message":
                if (fieldInfo.FieldType.ToString().Contains("vp_Message"))
                {
                    vp_Message e = (vp_Message)fieldInfo.GetValue(handler);
                    text2 = vp_EventDump.DumpEventListeners(e, new string[]
                    {
                        "Send"
                    });
                }
                break;

            case "vp_Attempt":
                if (fieldInfo.FieldType.ToString().Contains("vp_Attempt"))
                {
                    vp_Event e2 = (vp_Event)fieldInfo.GetValue(handler);
                    text2 = vp_EventDump.DumpEventListeners(e2, new string[]
                    {
                        "Try"
                    });
                }
                break;

            case "vp_Value":
                if (fieldInfo.FieldType.ToString().Contains("vp_Value"))
                {
                    vp_Event e3 = (vp_Event)fieldInfo.GetValue(handler);
                    text2 = vp_EventDump.DumpEventListeners(e3, new string[]
                    {
                        "Get",
                        "Set"
                    });
                }
                break;

            case "vp_Activity":
                if (fieldInfo.FieldType.ToString().Contains("vp_Activity"))
                {
                    vp_Event e4 = (vp_Event)fieldInfo.GetValue(handler);
                    text2 = vp_EventDump.DumpEventListeners(e4, new string[]
                    {
                        "StartConditions",
                        "StopConditions",
                        "StartCallbacks",
                        "StopCallbacks"
                    });
                }
                break;
            }
            if (!string.IsNullOrEmpty(text2))
            {
                string text3 = text;
                text = string.Concat(new string[]
                {
                    text3,
                    "\t\t",
                    fieldInfo.Name,
                    "\n",
                    text2,
                    "\n"
                });
            }
        }
        return(text);
    }