增加try catch防止中断流程

main
刘涛 2024-02-20 13:23:00 +08:00
parent d855fae793
commit 357f1ac945
1 changed files with 26 additions and 17 deletions

View File

@ -19,7 +19,7 @@ namespace Gameplay.Performance
public class PerformanceManager
{
private const string MAIN_RT = "Main_RT";
private static PerformanceManager _instance;
public static PerformanceManager instance
{
@ -47,7 +47,7 @@ namespace Gameplay.Performance
private PerformanceManager()
{
_Init();
// TEST
// data.enableTireMark = false;
}
@ -66,15 +66,15 @@ namespace Gameplay.Performance
// 创建一个新的 URP RendererFeature 实例,并将 HDR 选项设置为 true 或 false
bool enableHDR = data.enableHDR; // 设置为 true 启用 HDR设置为 false 禁用 HDR
urpAsset.supportsHDR = enableHDR;
// 更新 URP 的 Asset 实例,以应用修改的 HDR 选项
GraphicsSettings.renderPipelineAsset = urpAsset;
// 设置是否启用后处理
var mainCamera = CameraManager.Instance.MainCamera;
var urpCameraData = mainCamera.GetUniversalAdditionalCameraData();
urpCameraData.renderPostProcessing = data.enablePostOutline;
QualitySettings.shadows = data.enableShadow ? ShadowQuality.Disable : ShadowQuality.HardOnly;
Application.targetFrameRate = data.targetFrameRate;
SetResolution(data.resolution);
@ -85,8 +85,8 @@ namespace Gameplay.Performance
data.targetFrameRate = frameRate;
Application.targetFrameRate = data.targetFrameRate;
}
public void SetCloth(GameObject rootObj)
{
@ -146,7 +146,7 @@ namespace Gameplay.Performance
_SetRsoulution(Screen.width, Screen.height);
return;
}
var nowWidth = Screen.width;
var nowHeight = Screen.height;
if (nowHeight > nowWidth)
@ -174,11 +174,11 @@ namespace Gameplay.Performance
public static void ClearRaycasterImage()
{
LogCastSprite();
PointerEventData pointerEventData = new (EventSystem.current)
PointerEventData pointerEventData = new(EventSystem.current)
{
position = new Vector2(0, 0)
};
EventSystem.current.RaycastAll(pointerEventData,new List<RaycastResult>());
EventSystem.current.RaycastAll(pointerEventData, new List<RaycastResult>());
LogCastSprite();
}
@ -186,7 +186,7 @@ namespace Gameplay.Performance
{
var rayCaster = Object.FindObjectOfType<UIRoot>().Root.GetComponent<GraphicRaycaster>();
var type = rayCaster.GetType();
var m_RaycastResults = type.GetField("m_RaycastResults", BindingFlags.NonPublic| BindingFlags.Instance);
var m_RaycastResults = type.GetField("m_RaycastResults", BindingFlags.NonPublic | BindingFlags.Instance);
if (m_RaycastResults == null)
{
Debug.LogError("m_RaycastResults == null");
@ -205,12 +205,20 @@ namespace Gameplay.Performance
{
if (graphic is Image image)
{
DebugUtil.LogError($"sprite:{image.sprite?.name??"null"}");
try
{
DebugUtil.LogError($"sprite:{image.sprite?.name ?? "null"}");
}
catch (System.Exception e)
{
Debug.LogError(e);
}
}
}
}
private static void _SetRsoulution(int width, int height)
private static void _SetRsoulution(int width,
int height)
{
instance.screenScale = (float)width / Screen.width;
// Screen.SetResolution(width, height, Screen.fullScreenMode);
@ -218,7 +226,8 @@ namespace Gameplay.Performance
// _SetCameraRenderSize(CameraManager.Instance.SkillCamera, width, height);
}
private static void _SetCameraRenderSize(int width, int height)
private static void _SetCameraRenderSize(int width,
int height)
{
// if (rawCamera == null)
// {
@ -279,11 +288,11 @@ namespace Gameplay.Performance
// pc
performanceId = 3;
}
DebugUtil.Log("根据设备性能判断 : {0}", performanceId);
}
if (TableManager.Instance.Tables.PerformanceConfig.DataMap.TryGetValue(performanceId, out var pConfig))
{
data.enableShadow = pConfig.EnableShadow;