-
Notifications
You must be signed in to change notification settings - Fork 0
Variables Extending
Richard Kopelow edited this page Aug 5, 2018
·
2 revisions
SO Variables wrap data so references to it can easily setup in the editor.
- Create a new class file. A new file is necessary for Unity to properly link the code and the SO's asset file.
- Inherit from
BaseVariable<T>withTbeing the data type. - Give it a
CreateAssetMenuattribute.
[CreateAssetMenu(fileName = "NewByteVariable", menuName = "Scriptable Objects/Variables/Byte")]
public class ByteVariable : BaseVariable<byte> { } The Value class acts as an abstraction layer that makes it easy to switch between using SO Variables and hardcoded values.
- Inherit from
BaseValue<T, Y>withTbeing the data type andYbeing the Variable type. - Give it the
Serializableattribute.
[Serializable]
public class ByteValue : BaseValue<byte, ByteVariable> { }Custom property drawers are used to clean up the look of Value Fields in the editor while maintaining the flexibility gained by using a Value rather than simply referencing the SO Variable.
- Define a class that inherits from
ValueDrawer. (This need only be done once, it can be used for all custom variables) - Add a
CustomPropertyDrawerattribute to theValueDrawerclass.
[CustomPropertyDrawer(typeof(ByteValue))]- Events
- Variables
- Conditions
- Extras
- GUI Elements
- Systems