This repository was archived by the owner on May 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 117
References
Daniel Everland edited this page Oct 23, 2018
·
10 revisions
References are how we expose fields in MonoBehaviour scripts that allow us to assign a variable ScriptableObject. They're wrapped in a separate class because you can also choose not to use a ScriptableObject at all, and instead write a constant value in the inspector.
This is the default view, which allows us to assign a Variable.
You can click on the icon to the left of the field to change state.
"Use Constant" allows us to assign a value directly.
To create a Reference field in your MonoBehaviour script, simply declare it like you would any other field
public BoolReference boolValue;
Or use the [SerializeField] attribute if it's not public
[SerializeField]
private BoolReference boolValue;
You don't have to care whether the Reference is using a constant or a variable, simply reference the Value property
T Value { get; set; }