SetFamilyVariable
SetVariable
Method Documentation
Description
The SetVariable
methods allow for setting the value of a private variable for a family based on its name or ID. These methods come in two variants: a non-generic version that sets the value and a generic version that sets the value and returns the updated variable cast to a specified type.
Method Signatures
SetVariable (Non-Generic)
public void SetVariable(string variableNameOrId, object value)
This method sets the value of the variable with the specified name or ID for the family.
SetVariable (Generic)
public T SetVariable<T>(string variableNameOrId, object value) where T : NVar
This method sets the value of the variable with the specified name or ID for the family and returns the updated variable cast to the specified type T
.
Example Usage
Non-Generic Usage
IM.Player.Family.SetVariable("booleanVariable", true);
Sets the value of the booleanVariable
to true
.
Generic Usage
NBool booleanVar = IM.Player.Family.SetVariable<NBool>("booleanVariable", true);
Debug.Log(booleanVar.Value);
Sets the value of the booleanVariable
to true
and returns the updated variable cast to an NBool
type. The booleanVar.Value
property returns the value as a bool
.
Note: booleanVar.Value
will return the value as a boolean type (bool
).