/UnityEventDrawerEx

This plugin extends the UnityEventDrawer to display runtime calls in the inspector.

Primary LanguageC#MIT LicenseMIT

UnityEventDrawerEx

image

This plugin extends the UnityEventDrawer to display runtime calls in the inspector.

<< Description | Download | Usage | Development Note >>





Description

What is runtime call?

Button.onClick and Toggle.OnChangeValue etc. are known as UnityEvent.
UnityEvent has two types of callbacks:

  • Persistent call
    • You can add callbacks from the inspector.
    • You can add callbacks from a script using UnityEventTools.AddPersistentListener.
    • It is Serialized.
    • It is displayed in the inspector.
      persistent
  • Runtime call
    • You can add a callback from a script using UnityEvent.AddListener.
    • It is not serialized.
    • It is not displayed in the inspector.
      runtime

Display your runtime call

This plugin extends UnityEventDrawer to display runtime calls in inspector.
If runtime call is an instance method, its target is also displayed.
This plugin supports all events that inherit UnityEvent<T0> - UnityEvent<T0, T1, T2, T3> as well as UnityEvent.
Also, when the Persistent call is empty, UnityEvent is displayed compactly in inspector.

public class TestBehavior : MonoBehaviour
{
	[System.Serializable] public class TransformUnityEvent : UnityEngine.Events.UnityEvent<Transform>{};

	[SerializeField] TransformUnityEvent onYourCustomEvent = new TransformUnityEvent();
	
	void OnEnable()
	{
		onYourCustomEvent.AddListener(TestTransform);
	}
	
	void TestTransform(Transform t)
	{
		Debug.Log("TestTransform has called : " + t);
	}
}

image

If you like a development style that heavily uses Runtime calls (MVP pattern, etc.), we recommend using this plugin!

Features

  • Displays runtime calls in inspector
  • Expands/collapses the runtime call view
  • Displays instance method, its target is also displayed
  • When the Persistent call is empty, displays it compactly
  • Supports pro skin
  • Supports all components as well as uGUI components such as Button and Toggle
  • Supports EventTrigger





Usage

  1. Download UnityEventDrawerEx.unitypackage from Releases.
  2. Import the package into your Unity project. Select Import Package > Custom Package from the Assets menu.
  3. Add a runtime call, such as Button.onClick.AddListener (method).
  4. Information about the runtime call is displayed in inspector.
  5. Enjoy!
Requirement
  • Unity 5.5+ (included Unity 2018.x)
  • No other SDK are required





Development Note





License

  • MIT
  • © UTJ/UCL

Author

mob-sakai

See Also