Managing Shared Variables
Posted: Wed Jun 04, 2025 6:52 am
Hi, would like to know how can I set the variable values?
Currently, I have an enum file which keeps track of the variables and retrieve them at runtime as such.
While I could retrieve the values successfully, I don't know how to set its value? Or is there a better approach?
Currently, I have an enum file which keeps track of the variables and retrieve them at runtime as such.
Code: Select all
// PixelCrushers.DialogueSystem.Variable (snippet)
public List<Variable> Variables = DialogueManager.DatabaseManager.DefaultDatabase.variables;
public enum Variables
{
Alert,
FirstTutorial
}
public Variable GetVariable(Variables v)
{
return Variables.Find(x => x.Name == v.ToString());
}
private void test()
{
Debug.Log(GetVariable(Variables.FirstTutorial).InitialBoolValue); // get
GetVariable(Variables.FirstTutorial).InitialBoolValue = false; // set
}