【屏幕适配】添加屏幕适配查看SafeAreaGM功能
parent
71afb3a0f8
commit
5e9a3ad50d
|
|
@ -0,0 +1,46 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &568492060851936423
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3195879209322628929}
|
||||
- component: {fileID: 10068872987916196}
|
||||
m_Layer: 0
|
||||
m_Name: DebugScreenSafeArea
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &3195879209322628929
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 568492060851936423}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &10068872987916196
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 568492060851936423}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: de9fb561708b4e3fa8ea513b430e7ce6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d67959696f53444db61e19319aaf9c1
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
using UnityEngine;
|
||||
public partial class UIManager
|
||||
{
|
||||
private Rect _GetScreenSafeArea()
|
||||
{
|
||||
var area = Screen.safeArea;
|
||||
return area;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a31168cc0b0247ca91f254c8f7baaa5b
|
||||
timeCreated: 1701171897
|
||||
|
|
@ -57,7 +57,7 @@ public partial class UIManager
|
|||
_WindowMeta(UINameConst.UI_Loading, UIWindowLayer.Max);
|
||||
_WindowMeta(UINameConst.UIReconnect, UIWindowLayer.Max);
|
||||
_WindowMeta(UINameConst.UIReconnectConfirm, UIWindowLayer.Max);
|
||||
|
||||
_WindowMeta(UINameConst.UIScreenTest, UIWindowLayer.Normal);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -133,5 +133,6 @@ public static class UINameConst
|
|||
public static readonly string UI_LoginTips = "StartScene/New/UI_LoginTips";
|
||||
public static readonly string UI_Loading = "StartScene/New/UI_Loading";
|
||||
|
||||
public static readonly string UIScreenTest = "LevelSceneUI/New/UIScreenTest";
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject;
|
||||
using UnityEngine;
|
||||
using Framework;
|
||||
using PhxhSDK;
|
||||
|
||||
//屏幕相关debug类
|
||||
public class DebugScreen: Singlenton<DebugScreen>
|
||||
{
|
||||
public bool IsShowSafeArea;
|
||||
private GameObject _goSafeArea;
|
||||
|
||||
//显示安全区域
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void _DestroySafeArea()
|
||||
{
|
||||
Object.DestroyImmediate(_goSafeArea);
|
||||
_goSafeArea = null;
|
||||
}
|
||||
|
||||
public void DrawSafeAreaRect()
|
||||
{
|
||||
var rect = Screen.safeArea;
|
||||
GUI.Box(rect, "");
|
||||
}
|
||||
|
||||
public void DebugChangeShowAreaState()
|
||||
{
|
||||
if (IsShowSafeArea)
|
||||
{
|
||||
_ShowSafeArea();
|
||||
return;
|
||||
}
|
||||
|
||||
_DestroySafeArea();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: deff56b9bd074136a26bce68facc97c2
|
||||
timeCreated: 1701232072
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class DebugScreenMono: MonoBehaviour
|
||||
{
|
||||
private void OnGUI()
|
||||
{
|
||||
DebugScreen.Instance.DrawSafeAreaRect();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: de9fb561708b4e3fa8ea513b430e7ce6
|
||||
timeCreated: 1701232708
|
||||
|
|
@ -110,4 +110,18 @@ public partial class SROptions
|
|||
}
|
||||
}
|
||||
|
||||
[Category("屏幕适配")]
|
||||
public bool IsShowScreenSafeArea
|
||||
{
|
||||
get
|
||||
{
|
||||
return DebugScreen.Instance.IsShowSafeArea;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
DebugScreen.Instance.IsShowSafeArea = value;
|
||||
DebugScreen.Instance.DebugChangeShowAreaState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue