|
Modular Architecture V1.0.0
|
Modular architecture comes with 4 main features :
In this page I will briefly talk about how these can be used. It is reccomended you have been through the Installation Guide ( Here ) before reading through this.
Each of the 4 Main features of Modular architecture has it's own sample piece / demostration that shows off the functionality / theory behind it. These samples can be installed by opening up the package-manager window in your Unity project, finding the Modular Architecture package, moving to the samples view and importing the relevant sample(s) you want. All the samples are designed to be small in scope and easy to follow along with.
The Condition system allows you to create simple logic checks without writing code by comparing two values using a chosen operator.
To check if a player’s health is low:
This represents: PlayerHealth < 30
Call: condition.Evaluate() This returns true or false depending on whether the condition is met.
Conditions are fully data-driven, meaning they can be configured in the Inspector and reused across systems without modifying code.
The data system allows you to use either constant values or shared data assets interchangeably, without changing your code.
Choose how the value is provided:
Set Use Constant = true → speed = 5 OR Set Use Constant = false → assign a Float Variable asset
References / Variables are just data values, you can reference them directly with [Reference].value or implicity =[Reference], These values are also modifiable even when in the data asset ( data variable ).
The event system allows different parts of your game to communicate without being directly connected.
A GameEvent is a reusable asset that can be triggered from anywhere, and all registered listeners will respond automatically.
Trigger the event from code or inspector: gameEvent.Raise();
This will notify all subscribed listeners.
A listener automatically subscribes when enabled:
When the event is raised, the listener executes its response.
Game Events are used to:
Game Events act as global signals that systems can react to. Instead of calling each other directly, objects simply respond when an event is raised, making the project more modular and scalable.
The enum system allows traditional C# enums to be represented as ScriptableObject assets, making them more flexible and designer-friendly. Instead of being hardcoded in code, enum values can be created, referenced, and swapped like data.
Right click in your project asset browser, navigate to the create menu, in there you will find Modular Architecture>Enums>Create New Enum. This is how we define new enums, when you've created an enum it will be compiled into that same context asset browser.
This behaves like a normal enum but is stored as data.