【Unity】EventSystem の有効/無効

DEVELOP, Unity

namespace mira
{
    /// <summary>
    /// イベントシステムの 有効/無効設定。
    /// </summary>
    public class CustomEventSystem
    {
        private static UnityEngine.EventSystems.EventSystem s_eventSystem = null;
 
        /// <summary>
        /// EventSystemが有効化確認します。
        /// </summary>
        public static bool IsEnable()
        {
            if(s_eventSystem == null)
            {
                s_eventSystem = UnityEngine.EventSystems.EventSystem.current;
            }
            return s_eventSystem.enabled;
        }
 
        /// <summary>
        /// 有効にします。
        /// </summary>
        public static void Enable()
        {
            if(s_eventSystem == null)
            {
                s_eventSystem = UnityEngine.EventSystems.EventSystem.current;
            }
            s_eventSystem.enabled = true;
        }
 
        /// <summary>
        /// 無効にします。
        /// </summary>
        public static void Disable()
        {
            if(s_eventSystem == null)
            {
                s_eventSystem = UnityEngine.EventSystems.EventSystem.current;
            }
            s_eventSystem.enabled = false;
        }
    }    
}

Posted by kazupon