SelectionGrid isn`t saving in Custom Inspector

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.

Please,can you help?

Yannic :slight_smile:

Could you show us how you defined your class the custom inspector is for?

What do you mean exactly?I can`t post the code.
All things working,except this :wink:

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
}

Thanks,man.
You`re awesome.
Du kommst aus Deutschland? :slight_smile:

Jepp, Emsdetten, nahe Münster :wink:

Cool.Ich bin aus Hannover.
Bist du auch im deutschen(unoffiziellem) Forum?

Ja unter dem Nick “Marrrk”, aber bin da nicht sonderlich aktiv, allerhöchstens mal selten im Chat.