Quick Start
Creating Kassets' ScriptableObjects
Instances of Kassets can be created from the Create
context menu or from Assets/Create
menu bar. Simply right click in the Project window and select the type of instance you want to create.
Create a GameEvent
Instance
For GameEvent
instances, select any of the provided event types from Create/Kassets/Game Events/
Create a Variable
Instance
For Variable
instances, select any of the provided variable types from Create/Kassets/Variables/
Below are the preview of Kassets' Variable
instance on Inspector window.
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 the example above, Player
component's field Health
and HealthBarUI
component's field Health
both refer to the same FloatVariable
ScriptableObject
instance PlayerHealth
.
Since both components refer to the same variable instance, the float
value they refer to is shared.
Each component then manages its own need with the value without any coupling between components.
For instance, HealthBarUI
doesn't need to request the Health
value from the Player
component and the Player
component can manage its own Health
value without needing to distribute it to other components.
Raising and Subscribing to an Event
Both Player
and HealthBarUI
components manage their own instances of the shared PlayerHealth
value.
However, they still need a system of communication for accurate data sharing, which is where the Pub/Sub pattern becomes essential.
The Player
component, as the Publisher
, raises an event whenever there's a change to PlayerHealth
.
The HealthBarUI
component, the Subscriber
, listens for these events and updates the UI accordingly.
Therefore, even though both components manage their own instances, they are not completely independent - the sharing of accurate health data requires this Publisher-Subscriber relationship for effective communication.