> For the complete documentation index, see [llms.txt](https://ashobot.gitbook.io/ultimate-attributes-pack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ashobot.gitbook.io/ultimate-attributes-pack/conditionals.md).

# Conditionals

<details>

<summary>ShowIf</summary>

Displays the variable in the inspector only if the condition set with ComparisonType parameter is true between compared variable and condition value.

**Supported property types**

Everything.

**Parameters**

* ComparedVariableName
* ConditionValue
* ComparisonType
* DisablingType

#### Limitations

Compared variable and condition value must be the same type and only work with **bool**, **enum**, **float**, **int** and **string**.

<mark style="color:purple;">Code Example</mark>

```csharp
using UltimateAttributesPack;

public class ShowIfExample : MonoBehaviour
    {
        public bool showFloat;

        [ShowIf("showFloat", true)] // You can use it to show variables if a bool is on a specific state
        public float floatValue;

        [Space]

        public float showIntIfSuperiorTo5;

        [ShowIf("showIntIfSuperiorTo5", 5, ComparisonType.GreaterThan)] // You can also use it with numeric comparison
        public int intValue;

        [Space]

        public string showStringIfEqualTo4;

        [ShowIf("showStringIfEqualTo4", 4, ComparisonType.Equals)] // It also works with string lenght (characters number is the value)
        public string stringValue;

        [Space]

        public string writeYesToShow = "Yes";

        [ShowIf("writeYesToShow", "Yes", ComparisonType.Equals)] // It also works with string comparison
        public string secondStringValue;

        [Space]

        public bool readOnlyShowIf;

        [ShowIf("readOnlyShowIf", true, ComparisonType.Equals, DisablingType.ReadOnly)] // You can also set the disabling type to readonly if you want it to be visible in readonly in the inspector when it's disabled
        public string thirdStringValue;
    }
```

<img src="https://3496865040-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJRT3Vo5QZSbuYGZVtRD%2Fuploads%2FQqWgCMPyaw7z2s3tyTj6%2FShowIf.gif?alt=media&amp;token=2815e1a8-71ee-4c87-bf05-cbc45df7449c" alt="" data-size="original">

</details>

<details>

<summary>ShowOnlyInEditMode</summary>

Displays the variable in the inspector only if the project is in edit mode.

**Supported property types**

Everything.

**Parameters**

* DisablingType

<mark style="color:purple;">Code Example</mark>

```csharp
using UltimateAttributesPack;

public class ShowOnlyInEditModeExample : MonoBehaviour
    {
        // ShowOnlyInEditMode displays the variable only in edit mode
        [ShowOnlyInEditMode]
        public float floatValue;

        // You can also set the param to ReadOnly to show the variable in readonly when it's disabled
        [ShowOnlyInEditMode(DisablingType.ReadOnly)]
        public int intValue;
    }
```

<img src="https://3496865040-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJRT3Vo5QZSbuYGZVtRD%2Fuploads%2FDiEm9CvQPk9XnK55dMcI%2FShowOnlyInEditMode.gif?alt=media&amp;token=3980d868-c392-473c-b036-e1479c5aa6c1" alt="" data-size="original">

</details>

<details>

<summary>ShowOnlyInPlayMode</summary>

Displays the variable in the inspector only if the project is in play mode.

**Supported property types**

Everything.

**Parameters**

* DisablingType

<mark style="color:purple;">Code Example</mark>

<pre class="language-csharp"><code class="lang-csharp">using UltimateAttributesPack;
<strong>
</strong><strong>public class ShowOnlyInPlayModeExample : MonoBehaviour
</strong>    {
        // ShowOnlyInEditMode displays the variable only in edit mode
        [ShowOnlyInPlayMode]
        public float floatValue;

        // You can also set the param to ReadOnly to show the variable in readonly when it's disabled
        [ShowOnlyInPlayMode(DisablingType.ReadOnly)]
        public int intValue;
    }
</code></pre>

<img src="https://3496865040-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJRT3Vo5QZSbuYGZVtRD%2Fuploads%2FlPnptiNClZndjpa5g8HK%2FShowOnlyInPlayMode.gif?alt=media&amp;token=ee4ac2ab-bc71-45f0-8864-920949c1171f" alt="" data-size="original">

</details>

<details>

<summary>DoOnValueChanged</summary>

Executes a function if the variable change.

**Supported property types**

Everything.

**Parameters**

* FunctionName
* ClassType

<mark style="color:purple;">Code Example</mark>

<pre class="language-csharp"><code class="lang-csharp">using UltimateAttributesPack;
<strong>
</strong><strong>public class DoOnValueChangedExample : MonoBehaviour
</strong>    {
        // You can use it to execute a function if a value has changed
        [DoOnValueChanged("LogMessageOnValueChanged", typeof(DoOnValueChangedExample))]
        public float floatValue;

        void LogMessageOnValueChanged()
        {
            Debug.Log("The value has changed");
        }
    }
</code></pre>

<img src="https://3496865040-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJRT3Vo5QZSbuYGZVtRD%2Fuploads%2FpSJmmgsraFJ7dsCHcFJb%2FDoOnValueChanged.gif?alt=media&amp;token=e1fa0c49-b7d2-4629-8f05-f2e556569390" alt="" data-size="original">

</details>

***
