Search Unity

need help scripting a mouse cursor in on pause

Discussion in 'Editor & General Support' started by GayPirate, Apr 19, 2014.

  1. GayPirate

    GayPirate

    Joined:
    Apr 13, 2014
    Posts:
    2
    hi guys i need some help turning on and off my mouse cursor when i pause my game this what i have so far

    #pragma strict

    private var pauseGame : boolean = false;
    private var showGUI : boolean = false;

    function Update()
    {
    if(Input.GetKeyDown("escape"))
    {
    pauseGame = !pauseGame;

    if(pauseGame == true)
    {
    Time.timeScale = 0;
    pauseGame = true;
    GameObject.Find("Main Camera").GetComponent(MouseLook).enabled = false;
    GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = false;
    showGUI = true;
    }
    }

    if(pauseGame == false)
    {
    Time.timeScale = 1;
    pauseGame = false;
    GameObject.Find("Main Camera").GetComponent(MouseLook).enabled = true;
    GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = true;
    showGUI = false;
    }

    if(showGUI == true)
    {
    gameObject.Find("PausedGUI").guiTexture.enabled = true;
    }

    else
    {
    gameObject.Find("PausedGUI").guiTexture.enabled = false;
    }
    }