Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Cursor Button Lock and Area limitation

using UnityEngine;
public class CursorScript : 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), "Limited Cursor"))
        {
            Cursor.lockState = CursorLockMode.Confined;
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: C# if...else Statement 
Csharp :: C# Custom setter with parameter 
Csharp :: textbox center align winform 
Csharp :: c# access control from another thread 
Csharp :: shutdownHook c# 
Csharp :: design pattern for so many conditions c# 
Csharp :: c# Color Convert 
Csharp :: mock return exception c# 
Csharp :: c# (sharp) varibles 
Csharp :: translate english to spanish 
Csharp :: bubble sort recursive c# 
Csharp :: windows form button border color 
Csharp :: Wait some seconds without blocking UI execution 
Csharp :: c# check if list is empty 
Csharp :: c# switch expression 8.0 
Csharp :: save checkbox value to database c# 
Csharp :: c# ulong 
Csharp :: how to get the screen size in Tao.Freeglut 
Csharp :: export xml 
Csharp :: change color unity back and forth 
Csharp :: resharper render pages folder asp.net core 
Csharp :: sort number in dynamo 
Csharp :: c# use list as a paramter 
Csharp :: Handle all AggregateExceptions when using Task.Whenall() async 
Csharp :: c# psobject get value 
Csharp :: unity control physics of multiple simulation 
Csharp :: unity predicts rigidbody position in x seconds 
Csharp :: c# webclient ssl bypass 
Csharp :: Reading a date from xlsx using open xml sdk 
Csharp :: c# listview 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =