UltEvents is a Unity plugin which allows you to easily setup and configure persistent event callbacks via the Inspector. It serves the same purpose as the inbuilt UnityEvents, but has superior features with fewer restrictions and an improved Inspector interface which requires fewer clicks to perform individual tasks.
Download it for free and check out the Documentation to get started.
This is what a Pressure Plate that triggers a Boulder trap might look like. It uses the
TriggerEvents3D script which has several
UltEvents that it executes in response to Unity's physics trigger messages. Specifically, it is using
This was all done without writing any custom scripts and other than step #1, none of it could be done with a
- Deactivate the Pressure Plate's
Collider so it can't be triggered again.
- Apply some force to the Boulder's
Rigidbody to start it rolling down a hill.
- Get the position of the Pressure Plate.
- Play the Trap Trigger Click sound at that position.
UnityEvent. Keep reading to find out why.
UnityEvents can only call methods with the following parameter types:
string, or anything derived from
Step #2 of the example above uses
UltEvents support all those types as well as
Enum (regular and flags),
Vector (2, 3, 4),
UnityEvents can only call methods with 0 or 1 parameters.
Steps #2 and #4 of the example above both call methods with multiple parameters.
UltEvents support any number of parameters.
UnityEvents can only call
Step #4 of the example above uses this to call
UltEvents allow methods with any access modifiers, including
AudioSource.PlayClipAtPoint. Other common
static methods include
UnityEvents can only call methods which return
Steps #3 and #4 of the example above use this to get the
UltEvents allow methods with any return type and allows the returned value to be used as a parameter in methods that come later in the list. If the value is not used it will simply be ignored.
Transform.position and use that as the
position at which the sound should be played.
UltEvents also have a much better Inspector interface than
- Collapse the event into a single line to occupy less screen space.
- Parameterless functions only take a single line.
- Function parameter names are displayed. You can see the full method signature instead of only the name.
- Select a listener on a specific
Component when there is more than one of the same type on the target object.
- Drag listeners around to reorder them.
- Keyboard shortcuts and context menu functions allow you to easily Copy, Paste, Add, Delete, and even Invoke events.
- Better organized method selection menus which can be customised to suit your needs.
- Button to quickly find a similarly named method if the target is missing.
- Dynamic listeners are displayed in the footer (ones added by code).
Individual tasks also tend to require fewer clicks with
- Instead of needing to add a new listener then drag in a target, you can just drag the target onto the event header.
- Instead of needing to select a listener then press the remove button in the footer, each listener has its own remove button.
- If you assign a specific
Component as the target, it will immediately open the method selection menu which will let you select methods directly from that component instead of going through a sub-menu every time.
If you like this asset, please consider supporting me by buying some of my other assets:
- Animancer gives you the ability to play and control animations dynamically at runtime using simple scripts instead of manually configuring inflexible Animator Controllers that encourage bad programming practices.
- Inspector Gadgets provides a variety of enhancements to the Unity Editor which can be useful for anyone.
- Weaver lets you avoid littering your code with magic strings and provides a framework for generating procedural assets.