/// <summary>
 ///     Clears cursor lock.
 /// </summary>
 public static void ClearCursorLock()
 {
     CursorLock.Clear();
     CursorLocked     = false;
     Cursor.lockState = CursorLockMode.None;
     Cursor.visible   = true;
 }
        /// <summary>
        ///     Lock cursor under given name.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="state"></param>
        /// <param name="forceNewState">Force to update cursor in this frame.</param>
        public static void LockCursor(string source, bool state, bool forceNewState = false)
        {
            if (string.IsNullOrEmpty(source))
            {
                source = "default";
            }

            if (CursorLock.ContainsKey(source))
            {
                CursorLock[source] = state;
            }
            else
            {
                CursorLock.Add(source, state);
            }

            CursorLocked = true;
            foreach (var i in CursorLock)
            {
                if (i.Value)
                {
                    continue;
                }
                CursorLocked = false;
                break;
            }

            if (Instance == null || !forceNewState)
            {
                return;
            }

            Instance.InternalUpdateCursorState();
        }
Exemplo n.º 3
0
 public void TogglePause()
 {
     if (transitioning)
     {
         return;
     }
     pauseState     = !pauseState;
     Time.timeScale = pauseState ? 0f : 1f;
     canvas.enabled = pauseState;
     CursorLock.LockCursor(!pauseState);
 }
Exemplo n.º 4
0
 // Use this for initialization
 void Awake()
 {
     paused     = false;
     cursorLock = GetComponent <CursorLock> ();
     cursorLock.Lock();
     GameControllerRunnable[] initScripts = GetComponents <GameControllerRunnable> ();
     foreach (GameControllerRunnable gcr in initScripts)
     {
         gcr.Init();
     }
 }
Exemplo n.º 5
0
 private void Start()
 {
     lookScript = Camera.main.transform.GetComponent <CursorLock>();
 }
 /// <summary>
 ///     Gets state of cursor lock.
 /// </summary>
 public static bool GetCursorLock(string source)
 {
     return(CursorLock.ContainsKey(source) && CursorLock[source]);
 }
Exemplo n.º 7
0
    void Awake()
    {
        Singleton = this;

        LockCursor();
    }