title: pass variables between classes
body: <p>I just started with C# recently. I used PHP so I'm not into the syntax yet. </p>
  
  <p>I am using Unity and trying to send a variable between two classes. What I have is a mouse movement and a pause class. In the Mouse class I have a variable called state. If this is true the script runs and if false it doesn't. </p>
  
  <p>What I am wondering is how can I change this variable from another class. Since I was not successful in this, I made a class called vars for trying to make it work. No luck there ether.</p>
  
  <p>pauseMenu.cs</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using UnityEngine.UI;
  
  public class pauseMenu : MonoBehaviour {
  public bool isMenu = false;
  public Texture btnTexture;
  public bool isShown = false;
  public MouseLook mouse = new MouseLook();
  
  // Update is called once per frame
  void Start (){
  
  
  
      }
  void Update () {
       if (mouse.state== false) {
                      Debug.Log ("Some");
              }
              if (Input.GetKeyDown (KeyCode.P) || Input.GetKeyDown (KeyCode.Escape) &amp;&amp; isMenu == false) {
                      Debug.Log ("Show");
                      isShown = (isShown == false) ? true : false;
  
  
              }
              if (isShown) {
                      Screen.showCursor = true;
                      Screen.lockCursor = false;
                      mouse.state= false;
              }
      }
  void OnGUI()
  {
      if (isShown) {
  
          if (GUI.Button (new Rect (10, 10, 50, 50), "Quit")) {
              Application.Quit();
              Debug.Log("Quit");
          }
      }
  }
  }
  </code></pre>
  
  <p>MouseLock.cs</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  [AddComponentMenu("Camera-Control/Mouse Look")]
  
  public class MouseLook : MonoBehaviour {
  
  public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
  public RotationAxes axes = RotationAxes.MouseXAndY;
  public float sensitivityX = 15F;
  public float sensitivityY = 15F;
  
  public float minimumX = -360F;
  public float maximumX = 360F;
  
  public float minimumY = -60F;
  public float maximumY = 60F;
  float rotationY = 0F;
  public bool state { get; set; }
  
  void Update ()
  {
              if (state == true) {
                      if (axes == RotationAxes.MouseXAndY) {
                              float rotationX = transform.localEulerAngles.y + Input.GetAxis ("Mouse X") * sensitivityX;
  
                              rotationY += Input.GetAxis ("Mouse Y") * sensitivityY;
                              rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
  
                              transform.localEulerAngles = new Vector3 (-rotationY, rotationX, 0);
                      } else if (axes == RotationAxes.MouseX) {
                              transform.Rotate (0, Input.GetAxis ("Mouse X") * sensitivityX, 0);
                      } else {
                              rotationY += Input.GetAxis ("Mouse Y") * sensitivityY;
                              rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
  
                              transform.localEulerAngles = new Vector3 (-rotationY, transform.localEulerAngles.y, 0);
                      }
              }
      if (state == false) {
          Debug.Log ("false");
  
  
      }
      }
  
  void Start ()
  {
      state = true;
      //state = true;
      Debug.Log ("Started");
      // Make the rigid body not change rotation
      if (rigidbody)
          rigidbody.freezeRotation = true;
  }
  }
  </code></pre>