Cursor Lock State#
Input / Cursor / Cursor Lock State
Description#
Returns true if the mouse cursor is in the chosen lock state
Parameters#
| Name | Description |
|---|---|
| Lock State | The lock state the cursor is compared against |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Cursor Lock State")]
[Category("Input/Cursor/Lock State")]
[Description("Returns true if the mouse cursor is in the chosen lock state")]
[Image(typeof(IconCursor), ColorTheme.Type.Blue)]
[Keywords("Mouse", "Pointer", "Lock", "Locked", "Confined", "Free")]
[Parameter("Lock State", "The lock state the cursor is compared against")]
[Serializable]
public class ConditionCursorLockState : Condition
{
[SerializeField] private CursorLockMode m_LockState = CursorLockMode.Locked;
protected override string GetTitle(GameObject source)
{
string className = TextUtils.ThemeAsKeyword("Cursor");
string member = TextUtils.ThemeAsKeyword("Lock State");
return $"{className} {member} is {this.m_LockState}";
}
protected override bool Run(Args args)
{
return Cursor.lockState == this.m_LockState;
}
}
}