Expose protected variable in inspector

Hello !

I have two classes :

public class Slide : MonoBehaviour 
{ protected bool _auto = false; }

public class VideoSlide : Slide
{}

The question is : How could I expose the variable “_auto” in the inspector only for VideoSlide objects in the scene ?

I tried to do a Custom Editor, like that :

[CustomEditor(typeof(VideoSlide))]
public class VideoSlideEditor : Editor
{
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        var script = (VideoSlide)target;
        script.Auto = EditorGUILayout.Toggle("Auto",script.Auto);
        
    }
}

That works for exposing the variable in the editor, but when I press Play in the editor, the variable always go back to false even if i check the box !

Does someone know why ? :slight_smile:
Thanks for your help!

Did you try using [SerializeField]