Wednesday, September 9, 2015

Screen.lockCursor Cursor.visible in unity

iklan
using UnityEngine;
using System.Collections;

public class test : MonoBehaviour {
    bool isPlaying = false;
    void Start ()
    {
        Cursor.visible = false

    }
    
    void Update () 
    {
        if(Input.GetKey(KeyCode.Escape))
           {
            isPlaying = !isPlaying;
            
                if(isPlaying){
                    Screen.lockCursor = false//the cursor is unlocked from center
                    Cursor.visible = true;  //cursor is visible
                }
                else{
                    UnityEngine.Screen.lockCursor = true//the cursor is locked to center
                    Cursor.visible = false//cursor is invisibe
                }
            }
    }


}
Screen.lockCursor Cursor.visible in unity
4/ 5
Oleh