Variable synchronization
Posted: Sun May 14, 2023 10:44 am
Hi guys and Tony! I was wondering: is there a "smarter" way to do this.
I want to synchronize a variable that is stored in my GameManager with a variable in the dialogue system (to save it)
I came up with the idea of using the properties
Is there a smarter way to do it? Or better just write a saver for my variables (given that they are not currently used in dialogs)
I also wanted to know if there is a way to backsynchronize the variables from the dialogue system
Thanks!
I want to synchronize a variable that is stored in my GameManager with a variable in the dialogue system (to save it)
I came up with the idea of using the properties
Code: Select all
[SerializeField] [Range(0, 100)] private int _sanity;
public int sanity
{
get
{
_sanity = DialogueLua.GetVariable("Sanity").AsInt;
return _sanity;
}
set
{
_sanity = Mathf.Clamp(value, 0, 100);
DialogueLua.SetVariable("Sanity", _sanity);
}
}
I also wanted to know if there is a way to backsynchronize the variables from the dialogue system
Thanks!