The Scriptable Events are serializable unity events added to a ScriptableObject
. Create scene independent and reusable events with just a few lines of code.
Download this package to your disk. Open the package manager on Window > Package Manager and select the + button and click on the Add package from disk... option. Add the ScriptableEvents package.
Open the project manifest file under the Packages folder and add these lines to the dependencies:
"dependencies": {
...
"com.loophouse.scriptable-events":"https://github.com/luisoliveiras/scriptable-events.git",
...
}
Open the package manager on Window > Package Manager and select the + button and click on the Add package from git URL... option.
- Add the ScriptableEvents package from: https://github.com/luisoliveiras/scriptable-events.git
** You can also add it from disk if you want, just follow the steps from 2018.4 install guide.
Create a scriptable event asset from the Scriptable Events option on the Create menu. With this event you are able to register other scriptable objects to listen to the event from the inspector. You can also create a reference to it in a MonoBehaviour class and trigger the event using the method Invoke() or Invoke(T parameter).
Add a ScriptableEventListener component of the corresponding event type to your gameobject to be able to register your components' methods as listeners to the event.
You can also create events for your own types just following the examples in the samples folder.
What: This sample contains events and listeners to int
, float
, string
, bool
, Vector2
and Vector3
.
How: Import the sample and move the scripts to a folder of your preference. The "Scriptable Events" option will become available the Create menu.