using System.Diagnostics;
using UnityEngine;

namespace XGame.Framework
{
    public static class XOpencoding
    {
        private static GameObject _debugConsoleGO;

        [Conditional(MacroDefine.DEBUG), Conditional(MacroDefine.PROFILER)]
        public static void Initialize()
        {
            //加载并且实例预制
            _debugConsoleGO = Object.Instantiate(Resources.Load<GameObject>("DebugConsole"));
            Opencoding.LogHistory.LogHandler.ConsoleVisibleChangedEvent += OnConsoleVisibleChanged;
        }

        [Conditional(MacroDefine.DEBUG), Conditional(MacroDefine.PROFILER)]
        public static void Dispose()
        {
            Object.DestroyImmediate(_debugConsoleGO);
            _debugConsoleGO = null;
            Opencoding.LogHistory.LogHandler.ConsoleVisibleChangedEvent -= OnConsoleVisibleChanged;
        }

        /// <summary>
        /// DebugConsole事件
        /// </summary>
        /// <param name="isVisible"></param>
        private static void OnConsoleVisibleChanged(bool isVisible)
        {
            //冻结热区穿透
            //FingerGestureUtility.Freeze(isVisible);
        }
    }
}
