mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-21 23:58:49 -05:00
* Removed everything that talks about implementations in the Philopsophy section.
* Added notes from Ryan Hipple's talk to the philosophy section * Reintroduced the old overview page with changes from #416, since I believe it is * Removed all Admonitions, since they are not working in docusaurus v1 * Proof read and made corrections to variables transformers and tags pages. * Added changes in "creating atoms" from #416
This commit is contained in:
parent
668bd54442
commit
6e027e1c9a
@ -9,7 +9,7 @@
|
||||
- Tutorials
|
||||
- [Creating Atoms](./tutorials/creating-atoms.md)
|
||||
- [Variables](./tutorials/variables.md)
|
||||
- [Variables: PreChangeTransformers](./tutorials/variables-transformers.md)
|
||||
- [Variable Pre Change Transformers](./tutorials/variable-transformers.md)
|
||||
- [Events](./tutorials/events.md)
|
||||
- [Listeners](./tutorials/listeners.md)
|
||||
- [Actions](./tutorials/actions.md)
|
||||
|
@ -101,4 +101,4 @@ To dive right in, create your first Atom using any of the available techniques m
|
||||
|
||||
## Learn more
|
||||
|
||||
Go to [Overview and philosopy](./overview.md) to learn more about Unity Atoms and how to tune in to the correct mindset when using them.
|
||||
Go to [overview ](./overview.md) to learn more about Unity Atoms and how to tune in to the correct mindset when using them.
|
||||
|
@ -5,44 +5,118 @@ hide_title: true
|
||||
sidebar_label: Overview
|
||||
---
|
||||
|
||||
# UnityAtoms Documentation
|
||||
# Overview
|
||||
|
||||
UnityAtoms is a flexible and robust Unity-based framework that allows for scalable and reusable game development. It uses the idea of data-driven design, allowing you to easily create and manage game variables, events, and references, among other things.
|
||||
This chapter provides an overview of the building blocks and concepts of Unity Atoms. This knowledge helps you better understand a new way of thinking about data and state in your project.
|
||||
|
||||
## Overview
|
||||
## Fundamentals
|
||||
|
||||
Unity Atoms is an event based system that encourages the game to be as data-driven as possible. The five most fundamental building blocks of Unity Atoms are:
|
||||
|
||||
- Data
|
||||
- Events
|
||||
- Listeners
|
||||
- Responses
|
||||
- Collections
|
||||
|
||||
## Data
|
||||
|
||||
### Variables
|
||||
|
||||
Variables are data stored as [Unity's Scriptable Objects](https://docs.unity3d.com/Manual/class-ScriptableObject.html).
|
||||
|
||||
Because Variables are stored as Scriptable Objects they are not part of any scene, but could be instead be seen as part of a global shared game state. Variables are also designed to make them easy to inject (via the Unity Inspector) to your MonoBehaviours.
|
||||
|
||||
It is possible to attach an Event to a Variable that gets raised when its updated. This makes it possible to write more data-driven code. An Event attached to a Variable could contain only the new value (`Changed`) or contain both the new and the old value (`Changed With History`)
|
||||
|
||||
#### Pre Change Transformers
|
||||
|
||||
You can also add pre change transformers to a Variable. A pre change transformer is an AtomFunction that takes the value type of the Variable, performs some logic, and returns a new value of the same type. It's called on `OnEnable` as well as before setting a new Value of a Variable. An example of a pre change transformer is `ClampInt`, an `IntIntFunction` that clamps the Variable's value between two values.
|
||||
|
||||
Your pre change transformers can contain as much or as little logic as necessary for your project and you can chain them in the Inspector.
|
||||
|
||||
### Constants
|
||||
|
||||
Constants behave exactly the same as Variables, but can not be changed via script and therefore do not contain the change Events that Variables do.
|
||||
|
||||
### References
|
||||
|
||||
AtomReferences provide a versatile wrapper for the inspector, abstracting the source of a value. The only requirement is that the type of the underlying value is correct.
|
||||
References are values that can be toggled between `Use Value`, `Use Constant`, `Use Variable` or `Use Variable Instancer` via the Unity Inspector.
|
||||
|
||||
An `AtomReference` can point to an `AtomVariable`, `AtomConstant`, `AtomInstancer`, or a pure value.
|
||||
When a Reference is set to `Use Value` it functions exactly like a regular serialized variable in a MonoBehaviour script. However, when it is set to `Use Variable` or `Use Constant` it uses a Variable or a Constant. When it's set to `Use Variable Instancer` you can drag and drop a Variable Instancer of the correct type.
|
||||
|
||||
The `EventReferences` can point to an `AtomEvent` or `AtomEventInstancer`.
|
||||
### Variable Instancers
|
||||
|
||||
### Atom Variables
|
||||
This is a MonoBehaviour that takes a base Variable and makes an in memory copy of it `OnEnable`. This is particular useful when working with prefabs that are going to be instantiated at runtime. You can also give the Variable Instancer a reference to a List or a Collection. If you do that the Variable Instancer will add the in memory Variable on `Start` to the List or Collection and then later remove it on `OnDestroy`.
|
||||
|
||||
AtomVariables are assets that hold data. They can have AtomEvents assigned to raise whenever their value changes.
|
||||
### Pairs
|
||||
|
||||
- **AtomConstants**: These are runtime-readonly versions of AtomVariables, offering a way to use constant values in your game logic.
|
||||
Pairs are simple structs containing two variables of the same type, used for example in Variables' `Changed With History` Event.
|
||||
|
||||
- **AtomValueLists**: These are used to hold lists of AtomValues.
|
||||
## Events
|
||||
|
||||
### Event Bus
|
||||
### Events
|
||||
|
||||
- **AtomEvents** implement an event bus channel. They allow for values to be sent across the channel or objects to listen for them.
|
||||
An Event is a thing that happens in the game that Listeners can listen for. Events in Unity Atoms are also Scriptable Objects that live outside of a specific scene. It is possible to raise an Event from the Unity Inspector for debugging purposes.
|
||||
|
||||
- **AtomEventListeners**: AtomEventListeners act as the receivers in the AtomEvents system. They register on AtomEvents (potentially filter them via **AtomConditions**), waiting for values to be broadcasted and executing AtomActions (or more).
|
||||
### Pair Events
|
||||
|
||||
- *AtomConditions*, are like .NET `Predicate`. They may receive argument(s) and return a `bool`.
|
||||
- *AtomActions*, are like .NET `Action`. They may receive argument(s) and return `void`.
|
||||
- *AtomFunctions*, are like .NET `Func`. They may receive argument(s) and return a value.
|
||||
Like Event, but for pairs.
|
||||
|
||||
## Additions
|
||||
### Event References
|
||||
|
||||
Further features of UntiyAtoms are:
|
||||
- **Pairs** AtomVariables and Events can be wrapped around Tuples to provide multiple arguments on an event for example.
|
||||
- **Collections** Miscellanious Collections, one is a DictionaryAtom and the other a List of AtomVariables.
|
||||
Event References are Events that can be toggled between `Use Event`, `Use Event Instancer`, `Use Variable` or `Use Variable Instancer` via the Unity Inspector. When an Event Reference is set to `Use Event` it functions exactly like a regular serialized Event in a MonoBehaviour script. When it is set to `Use Event Instancer` you can drag and drop an Event Instancer whose Event the Event Reference will use. When it is set to `Use Variable` it is going to use the Event associated with the Variable's Changed Event. When it's set to `Use Variable Instancer` you can drag and drop a Variable Instancer of the correct type and it will use its associated Changed Event.
|
||||
|
||||
And even more (optional) Features are covered in their own Packages:
|
||||
- **FSM** a FiniteStateMachine Implementation based on Atoms
|
||||
- **Tags** an improvement over Unitys tagging system. Tag GameObjects based on UnityAtoms with efficient Lookup.
|
||||
### Event Instancers
|
||||
|
||||
This is a MonoBehaviour that takes a base Event and makes an in memory copy of it on `OnEnable`. This is particularly useful when working with prefabs that are going to be instantiated at runtime, for example when working with Mono Hooks on your prefabs.
|
||||
|
||||
### Pair Event Instancers
|
||||
|
||||
Like Event Instancer, but for pairs.
|
||||
|
||||
## Listeners
|
||||
|
||||
### Event Reference Listeners
|
||||
|
||||
A Listener listens to an Event reference and raises zero to many responses to that Event Reference. Listeners are MonoBehaviours that live in a scene. See below for more information on the type of responses that is supported.
|
||||
|
||||
### Pair Event Reference Listeners
|
||||
|
||||
Like Event Reference Listeners, but for pairs.
|
||||
|
||||
## Responses
|
||||
|
||||
Responses are raised by a Listener in response to an Event. Responses can live both in the scene as [UnityEvents](https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html) or outside the scene as a Scriptable Object in the shape of an Action.
|
||||
|
||||
### Actions
|
||||
|
||||
An Action in Unity Atoms is a C# function as a Scriptable Object. An Action can be used as a response in a Listener. Since Scriptable Objects can be created as assets in the project, Actions are well suited for responses that may have different default values.
|
||||
|
||||
### Pair Actions
|
||||
|
||||
Like Actions, but for pairs.
|
||||
|
||||
### Functions
|
||||
|
||||
A Function in Unity Atoms is basically the same as an Action, but while an Actions does not return something a Function does.
|
||||
|
||||
## Collections
|
||||
|
||||
Collections store multiple values. For all collections in Unity Atoms there is the possibility to add Events for the following:
|
||||
|
||||
- An item is added.
|
||||
- An item is removed.
|
||||
- The collection is cleared.
|
||||
|
||||
### Value Lists
|
||||
|
||||
A Value List is an array of values that is stored as a Scriptable Object.
|
||||
|
||||
### Lists
|
||||
|
||||
A List is an array of Variables that is stored as a Scriptable Object. The Variables stored in a List can be of different types.
|
||||
|
||||
### Collections
|
||||
|
||||
A collection is a set of Variables associated with a StringReference key and is stored as a Scriptable Object. The Variables stored in a Collection can be of different types.
|
@ -1,47 +1,31 @@
|
||||
---
|
||||
id: overview
|
||||
id: philosophy
|
||||
title: Philosophy
|
||||
hide_title: true
|
||||
sidebar_label: Overview and Philosophy
|
||||
sidebar_label: Philosophy
|
||||
---
|
||||
|
||||
:::caution
|
||||
# Philosophy
|
||||
|
||||
The following Content was (mostly) written by Chat-GPT and only proofread by Soraphis
|
||||
This page describes the foundation and philosophy of which Unity Atoms is built upon.
|
||||
|
||||
:::
|
||||
## ScriptableObject Architecture (SOA)
|
||||
[ScriptableObject](https://docs.unity3d.com/Manual/class-ScriptableObject.html) Architecture (SOA) is a design pattern that aims to facilitate scalable, maintainable, and testable game development using Unity. This concept was popularized by [Ryan Hipple in his 2017 GDC talk](https://www.youtube.com/watch?v=raQ3iHhE_Kk) where he introduced the concept of ScriptableObjects as the glue that makes it possible to create modular and data-driven systems within Unity.
|
||||
|
||||
# ScriptableObject Architecture (SOA) in Unity
|
||||
[Scriptable Object](https://docs.unity3d.com/Manual/class-ScriptableObject.html) Architecture (SOA) is a design pattern that aims to facilitate scalable, maintainable, and testable game development using Unity. This concept was popularized by [Ryan Hipple in his 2017 GDC talk](https://www.youtube.com/watch?v=raQ3iHhE_Kk) where he introduced the concept of ScriptableObjects as a way to create modular, data-driven systems within Unity.
|
||||
## Pillars of SOA
|
||||
|
||||
## The Philosophy of SOA
|
||||
The underlying philosophy of the SOA revolves around the following principles:
|
||||
There are 3 main pillars of SOA:
|
||||
|
||||
**Decoupling**: Reducing dependencies between components to make them more flexible and easier to maintain and test.
|
||||
**Modularity**: Creating self-contained, independent pieces that can be plugged together to build complex systems.
|
||||
**Data Oriented**: Centralizing and externalizing data for better management and debugging.
|
||||
ScriptableObject, a type of object in Unity that allows developers to create assets in the Unity Editor that store large amounts of shared data, is a key component in this architecture.
|
||||
- **Modular** - Systems in your game should not be directly depdendent on each other. Hard references between systems makes them less flexible and harder to reiterate on and reassemble. To make systems that are modular, it's a good rule to keep scenes as clean slates, meaning that we avoid `DontDestoryOnLoad` objects as much as possible. Furthermore, prefabs should as much as possible work on their own without any manager or other systems needed in the scene. Last but not least, Unity is a component based engine, create and use components that do one thing and one thing only.
|
||||
- **Editable** - The systems you create should be data-driven, eg. take data as input and process that data. The input and output of those systems should be editable and this is achieved by utilizing Unity's inspector. This approach allows us to change the game without changing code. Writing editable and with modular systems also allows us to reassemble systems in different ways, which is a great way to iterate on new game mechanics. Lastly, being editable means that we can change stuff at runtime, which greatly reduces iteration times.
|
||||
- **Debuggable** - If your systems are modular the easier they are to test in isolation. Furtermore, editable systems naturally provides debug views where you can see the data that is being processed.
|
||||
|
||||
## Key Pillars of SOA
|
||||
SOA relies heavily on two main pillars:
|
||||
## How SOA achieves its goals
|
||||
|
||||
**Modular Data**: Instead of hard coding data within our code, we externalize the data using ScriptableObjects. This allows for the separation of data and logic, making it easier to manage data and reuse it in different parts of the system.
|
||||
**Event Architecture**: This refers to the usage of ScriptableObjects as events (or event busses). In this system, ScriptableObjects act as channels where different parts of our system can subscribe to and broadcast events.
|
||||
- **Data** - Instead of hard coding data within our code, we externalize the data using ScriptableObjects. This allows for the separation of data and logic, making it easier to manage data and reuse it in different parts of the game.
|
||||
- **Events** - We use ScriptableObjects as events. This allows us to broadcast data across different parts of our game without having to know who is listening.
|
||||
|
||||
## UnityAtoms: An SOA Implementation
|
||||
UnityAtoms offers a robust implementation of the SOA. It's an extension of the ScriptableObject system, with a focus on making it easier to create and manage ScriptableObject-based code.
|
||||
## UnityAtoms: A SOA implementation
|
||||
UnityAtoms offers a robust implementation of the SOA. It's an extension of the ScriptableObject system, with a focus on making it easier to create and manage ScriptableObject-based code. It provides Variables, Instancers, Collections, Events, Actions, and Conditions, among others, which can be combined to implement complex game logic. Furthermore, it provides additional features built on top of the SOA architecture like FSM, Tagging, Input System and more.
|
||||
|
||||
### Features of UnityAtoms
|
||||
|
||||
**ScriptableObject Variables**: UnityAtoms allows for the creation of AtomVariables, ScriptableObjects containing values. It comes with a lot of built in types and provides easy code generation for custom types.
|
||||
**Game Events**: UnityAtoms uses AtomEvents, a form of ScriptableObject, to enable communication between scripts without direct references. These game events can be listened to by multiple scripts, allowing for a flexible and decoupled system.
|
||||
**Customizable and Extensible**: UnityAtoms is designed to be flexible and can be extended to suit the specific needs of your game project.
|
||||
|
||||
|
||||
### Using UnityAtoms
|
||||
UnityAtoms provides a collection of base classes that can be extended to create specific implementations for your game. It offers AtomVariable, Instancers, Collections, AtomEvent, AtomAction, and AtomCondition, among others, which can be combined to implement complex game logic.
|
||||
|
||||
Furthermore it offers additional features built on top of the SOA architecture like FSM, Tagging, Input and more.
|
||||
|
||||
## Conclusion
|
||||
SOA and UnityAtoms offer a great way to structure your Unity projects, providing a more maintainable, scalable, and testable codebase. The modular nature of this architecture allows for easy expansion of your game, ensuring that your codebase remains manageable as your game grows in complexity.
|
||||
SOA and UnityAtoms is a great way to structure your Unity projects, providing a more maintainable, scalable, and testable codebase. The modular nature of this architecture allows for easy expansion of your game, ensuring that your codebase remains manageable as your game grows in complexity.
|
||||
|
@ -5,21 +5,15 @@ hide_title: true
|
||||
sidebar_label: Tags
|
||||
---
|
||||
|
||||
:::caution
|
||||
|
||||
The following Content was (mostly) written by Chat-GPT and only proofread by Soraphis
|
||||
|
||||
:::
|
||||
|
||||
# Unity Atoms / Tags
|
||||
|
||||
A replacement to Unity´s tags based on Unity Atoms. See the [API](../api/unityatoms.tags) for more info.
|
||||
A replacement to Unity's tags based on Unity Atoms.
|
||||
|
||||
The **Tags** subpackage of Unity Atoms is a powerful tool enhances Unity's existing tag functionality by allowing for dynamic and scriptable tag operations.
|
||||
The **Tags** subpackage of Unity Atoms is a powerful tool that enhances Unity's existing tag functionality by allowing for dynamic and scriptable tag operations.
|
||||
|
||||
## Using the Tags Subpackage
|
||||
## Using the Tags subpackage
|
||||
|
||||
### Adding/Removing Tags from a GameObject
|
||||
### Adding and removing tags from a GameObject
|
||||
|
||||
To assign a tag to a GameObject, use the `AtomTags` component that comes with the AtomTags subpackage. The easiest way is to add the Tags in the Inspector, but it's also possible to add/remove tags at runtime using `StringConstants`:
|
||||
|
||||
@ -33,7 +27,7 @@ Tag tagComponent = gameObject.AddComponent<AtomTags>();
|
||||
tagComponent.AddTag(myTag);
|
||||
tagComponent.RemoveTag(myTag.Value);
|
||||
```
|
||||
### Get Tags of an GameObjects
|
||||
### Get tags of an GameObjects
|
||||
|
||||
To see if a GameObject has a specific tag:
|
||||
```
|
||||
@ -66,8 +60,5 @@ This will return all GameObjects with the tag "Enemy".
|
||||
|
||||
## Performance
|
||||
|
||||
The Tag packages is fine tuned to reduce heap allocations as much as possible, some results are discussed here: https://github.com/unity-atoms/unity-atoms/pull/12#issuecomment-470656166
|
||||
The Tag packages is fine tuned to reduce heap allocations as much as possible. Some results are discussed [here](https://github.com/unity-atoms/unity-atoms/pull/12#issuecomment-470656166).
|
||||
|
||||
## Conclusion
|
||||
|
||||
The Tags subpackage is a robust and dynamic tool that enhances the built-in tag functionality of Unity. By using scriptable tags, your code can become more flexible and maintainable.
|
||||
|
@ -11,6 +11,6 @@ There are several ways of creating Atoms in your project. The recommended way is
|
||||
|
||||
![creating-atoms](../assets/creating-atoms/atoms-creation.gif)
|
||||
|
||||
Another way to create Atoms is to select `Unity Atoms` in the context menu. The items are listed by category and by type. Custom Atom types created using the `Generator` (introduced by a later tutorial) also appear in this menu.
|
||||
Another way to create Atoms is to select `Unity Atoms` in the context menu. The items are listed by category and by type. Custom Atom types created using the `Generator` also appear in this menu (see the dedicated [generator tutorial](./generator.md) for more info on the generator).
|
||||
|
||||
In the following tutorials this is simply referred to as "creating an Atom" using any of the above mentioned techniques.
|
||||
|
54
docs/tutorials/variable-transformers.md
Normal file
54
docs/tutorials/variable-transformers.md
Normal file
@ -0,0 +1,54 @@
|
||||
---
|
||||
id: variable-transformers
|
||||
title: Variable Pre Change Transformers
|
||||
hide_title: true
|
||||
sidebar_label: Variable Pre Change Transformers
|
||||
---
|
||||
|
||||
# Variable Pre Change Transformers
|
||||
|
||||
Variable pre change transformers provide a way to modify the value of a Variable before it gets changed. These are used to introduce customized logic into the process of updating the value of an Variable. For example, a pre change transformer could be used to limit a player's health within certain boundaries, such as ensuring that it never drops below zero.
|
||||
|
||||
In this tutorial, we'll look at how to use a pre change transformer in UnityAtoms.
|
||||
|
||||
## Step 1: Create a Pre Change Transformer
|
||||
|
||||
Firstly, we need to create a new class for our pre change transformer. Let's say we are going to create a transformer that ensures the health of our player never falls below 0.
|
||||
|
||||
Create a new C# script and name it `MinHealthTransformer`. This script should extend `IntIntFunction` and override the `Call` method:
|
||||
|
||||
```
|
||||
using UnityAtoms.BaseAtoms;
|
||||
|
||||
[EditorIcon("atom-icon-sand")]
|
||||
[CreateAssetMenu(menuName = "Unity Atoms/Functions/Transformers/MinHealth Int (int => int)", fileName = "MinHealth")]
|
||||
public class MinHealthTransformer : IntIntFunction
|
||||
{
|
||||
public override int Call(int value)
|
||||
{
|
||||
if (value < 0)
|
||||
return 0;
|
||||
else
|
||||
return value;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In the `Call` method, we're checking if the new value of health is less than 0. If so, we're returning 0 instead of the new value. This ensures the player's health never drops below 0.
|
||||
|
||||
## Step 2: Use the Pre Change Transformer
|
||||
|
||||
To use this transformer, we need to create a ScriptableObject of this type.
|
||||
|
||||
In the Unity Editor:
|
||||
|
||||
1. Right-click in the project window and choose `Create > UnityAtoms > Functions > Transformers > MinHealth Int (int => int)`.
|
||||
2. Name the Object `MinHealthTransformer`.
|
||||
3. In the inspector window, set the `Pre Change Transform` to be `MinHealthTransformer`.
|
||||
|
||||
Now, whenever the `PlayerHealth` value is changed, the `MinHealthTransformer`'s `PreChangeCheck` method will be called, ensuring the health never drops below 0.
|
||||
|
||||
|
||||
## Notes
|
||||
|
||||
As the name suggests, pre change transformers are executed _before_ the change events are invoked.
|
@ -1,70 +0,0 @@
|
||||
---
|
||||
id: variables
|
||||
title: Variables
|
||||
hide_title: true
|
||||
sidebar_label: Variables
|
||||
---
|
||||
|
||||
:::note
|
||||
|
||||
This section is assuming, you've followed the [variables](variables.md) tutorial.
|
||||
|
||||
:::
|
||||
|
||||
:::caution
|
||||
|
||||
The following Content was (mostly) written by Chat-GPT and only proofread by Soraphis
|
||||
|
||||
:::
|
||||
|
||||
# Pre-Change Transformers in UnityAtoms
|
||||
|
||||
In UnityAtoms, pre-change transformers provide a way to modify the value of an Atom before it gets changed. These are used to introduce customized logic into the process of updating the value of an AtomVariable. For example, a pre-change transformer could be used to limit a player's health within certain boundaries, such as ensuring that it never drops below zero.
|
||||
|
||||
In this tutorial, we'll look at how to use a pre-change transformer in UnityAtoms.
|
||||
|
||||
## Step 1: Create a Pre-Change Transformer
|
||||
|
||||
Firstly, we need to create a new class for our pre-change transformer. Let's say we are going to create a transformer that ensures the health of our player never falls below 0.
|
||||
|
||||
Create a new C# script and name it `MinHealthTransformer`. This script should extend `AtomBaseVariable` and override the `PreChangeCheck` method:
|
||||
|
||||
```
|
||||
using UnityAtoms.BaseAtoms;
|
||||
|
||||
[EditorIcon("atom-icon-sand")]
|
||||
[CreateAssetMenu(menuName = "Unity Atoms/Functions/Transformers/MinHealth Int (int => int)", fileName = "MinHealth")]
|
||||
public class MinHealthTransformer : AtomBaseVariable<int>
|
||||
{
|
||||
public override int PreChangeCheck(int proposedChangeValue)
|
||||
{
|
||||
if (proposedChangeValue < 0)
|
||||
return 0;
|
||||
else
|
||||
return proposedChangeValue;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In the `PreChangeCheck` method, we're checking if the new value of health is less than 0. If so, we're returning 0 instead of the new value. This ensures the player's health never drops below 0.
|
||||
|
||||
## Step 2: Use the Pre-Change Transformer
|
||||
|
||||
To use this transformer, we need to create a ScriptableObject of this type.
|
||||
|
||||
In the Unity Editor:
|
||||
|
||||
1. Right-click in the project window and choose `Create > UnityAtoms > Functions > Transformers > MinHealth Int (int => int)`.
|
||||
2. Name the Object `MinHealthTransformer`.
|
||||
3. In the inspector window, set the `Pre Change Transform` to be `MinHealthTransformer`.
|
||||
|
||||
Now, whenever the `PlayerHealth` value is changed, the `MinHealthTransformer`'s `PreChangeCheck` method will be called, ensuring the health never drops below 0.
|
||||
|
||||
|
||||
## Notes
|
||||
|
||||
As the name suggests, pre-change transformers are execute _before_ the change events are invoked.
|
||||
|
||||
## Conclusion
|
||||
|
||||
Pre-change transformers provide a powerful way to introduce custom logic when changing the value of a variable in UnityAtoms. By understanding and utilizing these, you can create more versatile and adaptable gameplay systems.
|
@ -78,8 +78,12 @@
|
||||
"sidebar_label": "Installation"
|
||||
},
|
||||
"introduction/overview": {
|
||||
"title": "Overview and philosopy",
|
||||
"sidebar_label": "Overview and philosopy"
|
||||
"title": "Overview",
|
||||
"sidebar_label": "Overview"
|
||||
},
|
||||
"introduction/philosophy": {
|
||||
"title": "Philosophy",
|
||||
"sidebar_label": "Philosophy"
|
||||
},
|
||||
"introduction/preferences": {
|
||||
"title": "Preferences",
|
||||
@ -164,6 +168,10 @@
|
||||
"title": "Variable Instancer",
|
||||
"sidebar_label": "Variable Instancer"
|
||||
},
|
||||
"tutorials/variable-transformers": {
|
||||
"title": "Variable Pre Change Transformers",
|
||||
"sidebar_label": "Variable Pre Change Transformers"
|
||||
},
|
||||
"tutorials/variables": {
|
||||
"title": "Variables",
|
||||
"sidebar_label": "Variables"
|
||||
|
@ -2,6 +2,7 @@
|
||||
"docs": {
|
||||
"Introduction": [
|
||||
"introduction/installation",
|
||||
"introduction/philosophy",
|
||||
"introduction/overview",
|
||||
"introduction/preferences",
|
||||
"introduction/faq"
|
||||
@ -23,6 +24,7 @@
|
||||
"type": "subcategory",
|
||||
"label": "Intermediate",
|
||||
"ids": [
|
||||
"tutorials/variable-transformers",
|
||||
"tutorials/variable-instancer",
|
||||
"tutorials/event-instancer",
|
||||
"tutorials/generator",
|
||||
|
Loading…
Reference in New Issue
Block a user