> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/equipment-systems/prefab-and-object-manager/variables.md).

# Variables

Variables, which can be set on the `PrefabAndObjectManager` component, allow individual objects to only be activated if specific conditions are met. Currently `bool`, `float`, and `string` variables can be set, and each object can check for one variable value.

{% hint style="success" %}
If you have the [Dragons](https://assetstore.unity.com/packages/3d/characters/creatures/dragons-45330?aid=1100lxWw) character pack, the demo prefab has been updated to use variables to determine whether the saddle and similar objects should show, as well as whether the saddle or non-saddle version of the back options should show.
{% endhint %}

Click on the "Variables" tab, where you can name and add new variables. The name is how you set and get the variable values via code. You can also set a default value for each value type here.

![](/files/RcFsgVLrlM7e8CxUZWvJ)

Each object in each group now has the option of adding a variable. By default, no variable is selected, and variables will have no impact on the object. Once selected, you have the option to select which variable type (`bool`, `float`, or `string`), and the criteria, which is different for each type.

![](/files/YphNFx182xTC0nYJaovb)

In the example above, the "Carapace" will only activate when the `bool` value for "Saddle" is false, while "CarapaceSaddled" will only activate when the value is true.

Click the "Recycle" icon to remove the variable effect.

### Code Examples

Check the `PrefabAndObjectManager.cs` script to see all the new methods, with the most useful ones shown below.

{% code title="PrefabAndObjectManager.cs" %}

```csharp
// This will toggle the bool value of variableName, and then 
// reload all active shapes. (true is the default value)
prefabAndObjectManager.ToggleVariable(variableName, true);

// This will set a new float value for the variableName. It will
// NOT reload active shapes. You can pass in bool, float, or string
// values in.
prefabAndObjectManager.SetVariable(variableName, newFloatValue, false);
```

{% endcode %}
