55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
using BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject;
|
|
using UnityEngine;
|
|
using Framework;
|
|
using PhxhSDK;
|
|
using SRF;
|
|
|
|
//屏幕相关debug类
|
|
public class DebugScreen: Singlenton<DebugScreen>
|
|
{
|
|
public bool IsShowSafeArea;
|
|
private GameObject _goSafeArea;
|
|
private DebugScreenMono _debugScreenMono;
|
|
|
|
//显示安全区域
|
|
private async void _ShowSafeArea()
|
|
{
|
|
// 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)
|
|
{
|
|
_debugScreenMono = UIRoot.Instance.Root.AddComponent<DebugScreenMono>();
|
|
}
|
|
}
|
|
|
|
private void _DestroySafeArea()
|
|
{
|
|
// 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();
|
|
}
|
|
} |