revival/game/Assets/Scripts/Camera/HideandLockCursor.cs

27 lines
571 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HideandLockCursor : MonoBehaviour
{
2021-05-18 21:40:41 +02:00
[SerializeField] private bool _hideOnStart;
// Start is called before the first frame update
void Start()
2021-05-18 21:40:41 +02:00
{
if (_hideOnStart) HideCursor();
}
public void HideCursor()
{
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
}
2021-05-18 21:40:41 +02:00
public void ShowCursor()
{
2021-05-18 21:40:41 +02:00
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
}