title: Why in unity i'm getting the warning: You are trying to create a MonoBehaviour using the 'new' keyword?
body: <p>The full warning message:</p>
  
  <blockquote>
    <p>You are trying to create a <code>MonoBehaviour</code> using the <code>new</code> keyword.  This is not allowed. <code>MonoBehaviours</code> can only be added using <code>AddComponent()</code>. Alternatively, your script can inherit from <code>ScriptableObject</code> or no base class at all</p>
  </blockquote>
  
  <p>And in both scripts I'm not using the <code>new</code> keyword:</p>
  
  <p>The <code>DetectPlayer</code> script:</p>
  
  <pre><code>public class DetectPlayer : MonoBehaviour 
  {
      private int counter = 0;
  
      private void OnGUI()
      {
          GUI.Box(new Rect(300, 300, 200, 20),
              "Times lift moved up and down " + counter);
      }
  }
  </code></pre>
  
  <p>The <code>Lift</code> script:</p>
  
  <pre><code>public class Lift : MonoBehaviour 
  {
      private bool pressedButton = false;
      private DetectPlayer dp = new DetectPlayer();
  
      private void OnGUI()
      {
          if (pressedButton)
              GUI.Box(new Rect(300, 300, 200, 20), "Press to use lift!");
      }
  }
  </code></pre>