Files
Cielonos/Assets/OtherPlugins/GraphicsCat/Modules/Common/IMGUI/IMGUIEventBlocker.cs
SoulliesOfficial d15957c719 更新
2025-12-17 04:19:38 -05:00

43 lines
1.0 KiB
C#

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
namespace GraphicsCat
{
public class IMGUIEventBlocker
{
List<EventSystem> m_DisabledEventSystems = new();
public void OnGUI(Rect blockRect)
{
if (blockRect.Contains(Event.current.mousePosition * GameViewUtils.GetGameViewScale()))
{
BlockCurrentEventSystem();
}
else
{
UnblockAllEventSystems();
}
}
public void BlockCurrentEventSystem()
{
EventSystem es = EventSystem.current;
if (es != null)
{
es.enabled = false;
m_DisabledEventSystems.Add(es);
}
}
public void UnblockAllEventSystems()
{
foreach (var es in m_DisabledEventSystems)
{
if (es != null)
es.enabled = true;
}
m_DisabledEventSystems.Clear();
}
}
}