ShowInInspector is used on any member, and shows the value in the inspector.
Keep in mind that the ShowInInspector attribute will not serialize anything; meaning that any changes you make will not be saved with just the ShowInInspector attribute.
As a rule of thumb: Any field or property that isn't appearing in the inspector without the ShowInInspector attribute are not serialized.
Use the Serialization Debugger to get a better overview of what is and what isn't serialized in your classes.
[ShowInInspector]
private int myPrivateInt;
[ShowInInspector]
public int MyPropertyInt { get; set; }
[ShowInInspector]
public int ReadOnlyProperty
{
get { return this.myPrivateInt; }
}
[ShowInInspector]
public static bool StaticProperty { get; set; }
[SerializeField, HideInInspector]
private int evenNumber;
[ShowInInspector]
public int EvenNumber
{
get { return this.evenNumber; }
set { this.evenNumber = value - (value % 2); }
}
[ShowInInspector]
public static List<MySomeStruct> SomeStaticField;
[ShowInInspector, PropertyRange(0, 0.1f)]
public static float FixedDeltaTime
{
get { return Time.fixedDeltaTime; }
set { Time.fixedDeltaTime = value; }
}
[Serializable]
public struct MySomeStruct
{
[HideLabel, PreviewField(45)]
[HorizontalGroup("Split", width: 45)]
public Texture2D Icon;
[FoldoutGroup("Split/$Icon")]
[HorizontalGroup("Split/$Icon/Properties", LabelWidth = 40)]
public int Foo;
[HorizontalGroup("Split/$Icon/Properties")]
public int Bar;
}
[Button(ButtonSizes.Large), PropertyOrder(-1)]
public static void AddToList()
{
int count = SomeStaticField.Count + 1000;
SomeStaticField.Capacity = count;
while (SomeStaticField.Count < count)
{
SomeStaticField.Add(new MySomeStruct() { Icon = ExampleHelper.GetTexture() });
}
}
[OnInspectorInit]
private static void CreateData()
{
SomeStaticField = new List<MySomeStruct>()
{
new MySomeStruct(){ Icon = ExampleHelper.GetTexture() },
new MySomeStruct(){ Icon = ExampleHelper.GetTexture() },
new MySomeStruct(){ Icon = ExampleHelper.GetTexture() },
};
}