Skip to content

Storing and Accessing Variables

NeuroscienceScripts edited this page Jun 12, 2023 · 4 revisions

sXR handles variables to allow for global access and persistence after closing the Unity Editor. This is done by using Unity's PlayerPrefs and should not be used to store things like passwords or sensitive data. The variables are stored in the computer's registry and should be limited to storing <1MB of data (which should still allow for thousands of normal string/float/int/bool values). PlayerPrefs can only store one copy of each variable in each project. This means if SetInt() is used anywhere, it will change that integer value for all subsequent calls to GetInt().

Variables can be added, set, and viewed in the Unity Editor: AddChangeInt

Likewise, variables can be removed with the editor: Removal

The variables can also be set in any C# script using sxr.SetInt(), sxr.SetFloat(), sxr.SetString(), or sxr.SetBool(): SetCode (Users can also use sxr.SetPref() and it will automatically store the variable as the input data type)

And finally, all the variables can be accessed in scripts with sxr.GetInt(), sxr.GetFloat(), sxr.GetString(), or sxr.GetBool(): GetCode

Clone this wiki locally