title: How to set initial values for custom inspector fields in unity
body: <p>I have two similar classes <code>ClassA</code> and <code>ClassB</code>. Both classes contain a bool:</p>
  
  <p>In Class A:</p>
  
  <pre><code>[SerializeField]
  private bool _overwrite = true;
  
  public bool overwrite
  {
      get { return _overwrite; }
      set { _overwrite = value; }
  }
  </code></pre>
  
  <p>In Class B:</p>
  
  <pre><code>[SerializeField]
  private bool _hide = true;
  
  public bool hide
  {
      get { return _hide; }
      set { _hide = value; }
  }
  </code></pre>
  
  <p>Both scripts have a <code>CustomEditor</code> script. In both Editor scripts, inside the <code>OnInspectorGUI()</code> method the following two lines are used to add the respective bool's to the Inspector.</p>
  
  <p><code>ClassA.overwrite = EditorGUILayout.ToggleLeft("Overwrite", ClassA.overwrite);</code></p>
  
  <p><code>ClassB.hide = EditorGUILayout.ToggleLeft("Hide", ClassB.hide);</code></p>
  
  <hr>
  
  <p>When I add ClassA to a GameObject, the "Overwrite" field is unchecked, however when I add ClassB to a GameObject, the "Hide" field is checked.</p>
  
  <p>I don't understand what is different, or what other factor is involved in setting a default / initial value for a property.</p>
  
  <p>Ideally I want them both to be checked by default.</p>
  
  <p>Any ideas what I might be missing?</p>
  
  <p>Thanks for your time,</p>
  
  <p>Liam</p>