Using Kassets' ScriptableObject Instances
Usage on MonoBehavior Script
Create a MonoBehavior
Script and add Kassets' instance as a serialized field.
Player.cs
:

HealthBarUI.cs
:

Drag and drop PlayerHealth
(FloatVariable
) to Player
's Health
field :

Drag and drop PlayerHealth
(FloatVariable
) to HealthBarUI
's Health
field :

From example above, Player
component's field Health
and HealthBarUI
component's field Health
both refer to the same FloatVariable ScriptableObject instance PlayerHealth
. Since both component refer to the same variable instance, the float
value they refer to is shared. Each component then manage their own need with the value without any coupling between components. I.e. HealthBarUI
doesn't have to request the Health
value to Player
component and Player component can manage its own Health
without the need to distribute its value to other components.
Usage on UnityEvents
Kassets’s instance is a ScriptableObject asset. It can be referenced to UnityEvent via Inspector. You can aslo use dynamic method call on UnityEvent to pass a parameter.