AddAndRemoveVariablesForType
Introduction
Code Example
public override void StartUp()
{
this.AddAndRemoveVariablesForType += HandleAddAndRemoveVariablesForType;
}private void HandleAddAndRemoveVariablesForType(string type, Gum.DataTypes.Variables.StateSave stateSave)
{
if (type == "Sprite")
{
// Add startup logic here:
var variableToAdd = new Gum.DataTypes.Variables.VariableSave();
variableToAdd.Name = "MyCustomVariable";
variableToAdd.Type = "float";
variableToAdd.Value = 1.0f;
variableToAdd.IsFile = false;
variableToAdd.Category = "Plugin 1 Category";
// We must mark this as true if we want the default value to be used:
variableToAdd.SetsValue = true;
stateSave.Variables.Add(variableToAdd);
}
}
Variable removal
Additional Examples
Last updated
Was this helpful?

