Question by 
               MisterYeti · Jun 13, 2019 at 12:12 PM · 
                editorvariableinspector  
              
 
              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 ? :) Thanks for your help!
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
The variables modified in the inspector are not kept on build 0 Answers
CustomEditor on Inspector, Text too big to be fully rendered 0 Answers
How to save a two-dimensional array, as part of the variable inspector? 0 Answers
Why does Unity use the default values for my Serializable objects while running? 1 Answer