ProjectDDD/Assets/Plugins/Pixel Crushers/Common/Scripts/UI/ShowCursorWhileEnabled.cs
2025-07-08 19:46:31 +09:00

31 lines
922 B
C#

using UnityEngine;
namespace PixelCrushers
{
/// <summary>
/// Shows the cursor when this component is enabled. Typically add to a UI.
/// When the UI GameObject is activated, the component becomes enabled and
/// shows the cursor, if the InputDeviceManager is in Mouse mode or if there's
/// no InputDeviceManager in the scene.
/// </summary>
[AddComponentMenu("")] // Use wrapper.
public class ShowCursorWhileEnabled : MonoBehaviour
{
void OnEnable()
{
if (InputDeviceManager.instance == null || InputDeviceManager.deviceUsesCursor)
{
CursorControl.SetCursorActive(true);
}
}
void OnDisable()
{
if (InputDeviceManager.instance == null || InputDeviceManager.deviceUsesCursor)
{
CursorControl.SetCursorActive(false);
}
}
}
}