12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.Serialization;
- using System;
- using System.Text;
- using System.Collections;
- using System.Collections.Generic;
- using Sfs2X.Core;
- using Random = UnityEngine.Random;
- public class DebugManager : MonoBehaviour
- {
- #region Config
- public static Text Lab
- {
- get
- {
- if (Lab_ == null)
- {
- Lab = ResourceManager.Get<Text>(ObjectLabel.E_ScrrLab, false);
- }
- return Lab_;
- }
- set { Lab_ = value; }
- }
- private static Text Lab_;
- public int Counter;
- public float Timer;
- #endregion
- public void Update()
- {
- Timer += Time.deltaTime;
- Counter++;
- if (Timer >= 1)
- {
- //Log($"当前帧率 {Counter} 目标帧率 {Application.targetFrameRate}");
- Timer = 0;
- Counter = 0;
- }
- }
- public static void Log(string message)
- {
- if (Lab == null)
- {
- return;
- }
- Lab.text += '\n' + message;
- }
- public static void TryCatch(Action tryAction, Action catchAction)
- {
- try
- {
- tryAction.Invoke();
- }
- catch (Exception)
- {
- catchAction.Invoke();
- }
- }
- public static void PrintKeysAndValuesOfBaseEvent(string seperator, BaseEvent baseEvent)
- {
- Debug.LogWarning(seperator);
- foreach (var key in baseEvent.Params.Keys)
- {
- Debug.Log("Key " + key);
- }
- foreach (var value in baseEvent.Params.Values)
- {
- Debug.Log("value " + value);
- }
- Debug.LogWarning(seperator);
- }
- }
|