Hi everyone, there is a really good thread about Unity Events and the guys there were discussing about the current event Unity v5.x system limitations.
Current Unity Event System limitations:
-Nonexistent way for re-arrange events execution order.
-Methods with multiple parameter values are not supported.
-Methods with default parameter values are not supported.
-VectorX as a parameter is not supported.
-Color as a parameter is not supported.
I think UnityEvents are on the right path but the way they are now are currently too simple, at least inspector wise, and for me this is a big thing.
This is why I decided to start making my own custom version of a UI event system based on previous implementations and I wanted to share it with the community. You can download the latest version from the Asset Store here: Event Delegate System.
There is also a GitHub repo for the Event Delegate System if you want to dive in the code and help improving this out.
Event Delegate System features:
-Easy way for reordering events, like a drag and drop kind style!
-Unlimited parameters.
-Support for properties and fields.
-Supporting usage of methods from Components and GameObjects.
-Support for static methods and methods with return values.
-Support for methods with default parameters values.
-Support for Enum, Enum Flags, Vector2, Vector3, Vector4 and Color as parameters.
-Parameter mode, you can setup either a value or a reference.
-Allow folding the entire event list for visualization clarity.
Easy to use!:
using UIEventDelegate;
public class EventTest : MonoBehaviour
{
public ReorderableEventList OnEnableEvents;
void OnEnable()
{
if (OnEnableEvents.List.Count > 0)
EventDelegate.Execute(OnEnableEvents.List);
}
}
Event Display:
Method menu selection:
Current Version
v12.3
-Refresh rate optimization added for delegates visualization. (thanks to Froghuto)
v12.2
-Added option to visualize enums as flags.
-Bug fixes.
v12.1
-Adding the ability to refresh a target component’s functions manually. (request from QuantumCalzone)
-Using toggle on label click for easier fold-out (request from Jay-Pavlina)
-Allow folding the entire event list for visualization clarity.
-Improving check for Unity version. Adding support for Unity 2017 or newer versions.
Changelog
v12
-Support for properties and fields.
-Supporting usage of methods from Components and GameObjects.
-Improved list height calculation.
-Private methods are not being showed anymore.
-Removing indent level of parameters below method.
-Avoiding the use of foreach instructions to avoid heap allocations that will eventually trigger the garbage collector. Also loops micro improvements implemented.
-Minor code cleanup.
v11
-Allow the use of flags with enum types.
-Added ability to change a method while in Play mode and thus enabling tests without stopping gameplay. Previously it was using the first executed method saved in cache.
-EventDelegate drawer optimizations. Just asking once for the use of Parameter mode (Value or Reference) per parameter.
-Parameters are not requested again only if in editor mode (for testing purpose) or if the parameter is a reference. We assume value parameters will never change in the realtime deployed app.
-Added missing error log in case a method invoke failed when no arguments expected.
-Some minor code cleanup.
v10.1
-Issue affecting methods using void template as return type is now solved.
v10
-Reoderable feature implemented. Easy way for reordering events, like a drag and drop kind style!
-Enum support implemented.
-Parameter mode, you can setup either a value or a reference. You can now select any property to be a reference from a GameObject or using a manual value in the inspector.
-Issues calculating height fixed. Added offset option for overlap issue in reorderable event list.
-Fixed fold group indent level.
v9
-Support for Vector2, Vector3, Vector4 and Color as parameters.
-EventDelegate added to UIEventDelegate namespace to avoid name collision.
-Adding a “<Missing - ‘previous method name’>” when method was not found.
-Improved memory usage and performance when drawing events by avoiding the creation of a new EventDelegate object per draw, only for confirming existence. Now only one is created at startup.
-Fixed issue for components with some specific return value types.
Known issue:
-When Inspector width is below a very small threshold the Vector2 and Vector3 attributes will get drawn below their respective lines.
v8
-Support for non-public and static methods.
-Overloaded methods are now correctly filtered.
v7
-Support for methods with return values.
-Showing previous name method when used method has gone missing, like: <Missing - MethodName>.
-Parameters removed for selected method. We only show the name of the selected method since parameters are already been shown, and it clears the event display quite a bit.
v6
-Support for methods with multiple and default parameters values.
-Methods are displayed sorted and showing parameter type and name.
Future improvements:
-Add an easy built in method to add or remove events via scripts. Helpful for building EventDelegates during runtime.
-Add the ability to refresh a target component’s functions manually.
-Allow folding the entire event list for visualization clarity.
-Create “Examples” scene.
-Support for overloaded methods.
-Support for generic methods. (Beware that currently generics methods are not being filtered)
-Memory footprint optimization using lordofduct ‘parameter class’ implementation as reference.
-Allow to distinguish between different components in the same GameObject.
I deeply hope that this goes as a starting point in the interest to point out Unity how important would be to support this in the UI system, having this features shipping with Unity would be the ideal case!
Please let me now any suggestion, feature request or pizza donations be my guest!
You can also send some pizza donations here:
Best regards,
Lermy