Hi Community,
Ive programmed a custom inspector. There is a selectedInt = GUILayout.SelectionGrid(selectedInt,selectedStrings,3); in it. But it isnt “saving” in the editor,when I`ve clicked on one field of the SelectionGrid and then click on another Object.
Well the selectedInt integer wont be serialized/saved when this variable only resides inside your custom inspector or when its a non public field without SerializeField attribute, or when its a property.
public class Foo : MonoBehaviour
{
private int selectedInt; // wont serialize
protected int selectedInt; // wont serialize
internal int selectedInt; // wont serialize
int selectedInt; // wont serialize
public int selectedInt { get; set; } // wont serialize
public int selectedInt; // will serialize
[SerializeField]
private int selectedInt; // will serialize
}
public class Bar : Editor
{
public int selectedInt; // wont serialize
}