NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Debug/DebugScreen.cs

55 lines
1.4 KiB
C#
Raw Normal View History

using BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject;
using UnityEngine;
using Framework;
using PhxhSDK;
2024-08-29 15:29:09 +08:00
using SRF;
//屏幕相关debug类
public class DebugScreen: Singlenton<DebugScreen>
{
public bool IsShowSafeArea;
private GameObject _goSafeArea;
2024-08-29 15:29:09 +08:00
private DebugScreenMono _debugScreenMono;
//显示安全区域
private async void _ShowSafeArea()
{
2024-08-29 15:29:09 +08:00
// var prefabPath = "Assets/Art/UI/Prefab/Debug/DebugScreenSafeArea.prefab";
// var asset = await AssetManager.Instance.LoadAssetAsync<GameObject>(prefabPath);
// if (!_goSafeArea)
// {
// _goSafeArea = Object.Instantiate(asset, UIRoot.Instance.Root.transform);
// }
if (!_debugScreenMono)
{
2024-08-29 15:29:09 +08:00
_debugScreenMono = UIRoot.Instance.Root.AddComponent<DebugScreenMono>();
}
}
private void _DestroySafeArea()
{
2024-08-29 15:29:09 +08:00
// Object.DestroyImmediate(_goSafeArea);
// _goSafeArea = null;
UIRoot.Instance.Root.RemoveComponentIfExists<DebugScreenMono>();
_debugScreenMono = null;
}
public void DrawSafeAreaRect()
{
var rect = Screen.safeArea;
rect.height = -rect.height;
rect.y = Screen.height - rect.y;
GUI.Box(rect, "");
}
public void DebugChangeShowAreaState()
{
if (IsShowSafeArea)
{
_ShowSafeArea();
return;
}
_DestroySafeArea();
}
}