You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/Feel/MMTools/Tools/MMGUI/MMCursorVisible.cs

35 lines
897 B
C#

3 months ago
using UnityEngine;
using System.Collections;
using System;
using UnityEngine.UI;
using MoreMountains.Tools;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this class to an object and it'll make sure that the cursor is either visible or invisible
/// </summary>
[AddComponentMenu("More Mountains/Tools/GUI/MMCursorVisible")]
public class MMCursorVisible : MonoBehaviour
{
/// The possible states of the cursor
public enum CursorVisibilities { Visible, Invisible }
/// Whether that cursor should be visible or invisible
public CursorVisibilities CursorVisibility = CursorVisibilities.Visible;
/// <summary>
/// On Update we change the status of our cursor accordingly
/// </summary>
protected virtual void Update()
{
if (CursorVisibility == CursorVisibilities.Visible)
{
Cursor.visible = true;
}
else
{
Cursor.visible = false;
}
}
}
}