目次
「ShowIf」「HideIf」属性
「ShowIf」属性を使用すると
条件を満たしている場合に変数やプロパティが表示されるようになります
「HideIf」属性を使用すると
条件を満たしている場合に変数やプロパティが非表示になります
using Sirenix.OdinInspector; using UnityEngine; public class Example : MonoBehaviour { public bool isEnable; [ShowIf( "isEnable" )] public int a1; [HideIf( "isEnable" )] public int a2; private bool IsEnable() { return isEnable; } [ShowIf( "isEnable" )] public int b1; [HideIf( "IsEnable" )] public int b2; }
使い方
下記の様に記述するだけで使用できます
引数には bool 型の変数の名前を指定します
public bool isEnable; [ShowIf( "isEnable" )] public int a1; [HideIf( "isEnable" )] public int a2;
引数には bool 値を返す関数の名前を指定することもできます
private bool IsEnable() { return isEnable; } [ShowIf( "isEnable" )] public int b1; [HideIf( "IsEnable" )] public int b2;
参考サイト様
Odin Inspector and Serializer | Improve your workflow in Unity
Odin Inspector and Serializer | Improve your workflow in Unity