Unity 6.3
0 онлайн 83 гостей 3 в системе
Вход

CursorLockMode.Locked

Описание

Блокирует курсор в центре представления Game.

CursorLockMode.Locked также скрывает аппаратный курсор. Однако курсор блокируется и скрывается только после нажатия в представлении Game.

Android: Поддерживается только на Android 8.0 (API 26) или более новом.

//This script makes Buttons that control the Cursor's lock state. Note that the Confined mode only works on Windows and Linux Standalone platform build.

using UnityEngine;

public class Example : MonoBehaviour { void Update() { //Press the space bar to apply no locking to the Cursor if (Input.GetKey(KeyCode.Space)) Cursor.lockState = CursorLockMode.None; }

void OnGUI() { //Press this button to lock the Cursor if (GUI.Button(new Rect(0, 0, 100, 50), "Lock Cursor")) { Cursor.lockState = CursorLockMode.Locked; }

//Press this button to confine the Cursor within the screen if (GUI.Button(new Rect(125, 0, 100, 50), "Confine Cursor")) { Cursor.lockState = CursorLockMode.Confined; } } }