This is an Event System that is implementing 'Observer Pattern' using ScriptableObject
.
Ref : 3 cool ways to architect your game with Scriptable Objects
You can create event 'asset's in the project folder, and reference it from any GameObjects in any Scenes. This is especially useful if you want to connect UIs and GameObject instances throughout the scenes.
This pattern has the following advantages :
- Modular No direct references are needed between GameObject instances. This makes GameObjects easy to be saved as prefabs.
- Editable Change in one script doesn't affect others.
- Debuggable Modularized scripts are easy to be debugged.
This is a Plus
Designer-friendly : Exposed in the inspector and no scripting is needed.
This repo can be imported to your project as a submodule. In Unity, This will be treated as a custom package.
- Add this repo as a submodule to your project. Clone at
YourProject/Packages/Omni-Events
. If you are not familiar with submodule, modifyYourProject/Packages/manifest.json
file as follows :
"dependencies": {
...
"com.ngc6543.omnievents": "https://github.com/niguiecandy/omni-events.git",
...
},
- OmniEvent Assets
- Right-click on the Project panel, and Select 'Omni Events/...' to create an event asset.
- Various types of parameters are supported.
- OmniEventListener Components
- Add an OmniEventListener component of matching parameter to a GameObject, and assign event asset(s).
- Add any public method or property of the same parameter to
Invoked
UnityEvent.
- OmniEventInvoker Components
- Inspector helper components for debugging / easy invoking.