Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/LE_LevelEditor/Example/DebugScript.cs
2026-02-21 16:45:37 +08:00

93 lines
2.4 KiB
C#

using UnityEngine;
using UnityEngine.SceneManagement;
namespace LE_LevelEditor.Example
{
public class DebugScript : MonoBehaviour
{
private string m_debugString = string.Empty;
private int m_linesCount;
private float m_timeFPS;
private int m_counterFPS;
private int m_fps;
private Rect m_qualityUpBtnRect;
private Rect m_qualityLabelRect;
private Rect m_qualityDownBtnRect;
private void Awake()
{
Application.logMessageReceived += HandleLog;
if (SceneManager.GetActiveScene().name != "LE_ExampleGame")
{
m_qualityUpBtnRect = new Rect(0f, Screen.height - 108, 67f, 35f);
m_qualityLabelRect = new Rect(0f, Screen.height - 73, 67f, 38f);
m_qualityDownBtnRect = new Rect(0f, Screen.height - 35, 67f, 35f);
}
else
{
m_qualityUpBtnRect = new Rect(Screen.width - 67, 0f, 67f, 35f);
m_qualityLabelRect = new Rect(Screen.width - 67, 35f, 67f, 38f);
m_qualityDownBtnRect = new Rect(Screen.width - 67, 73f, 67f, 35f);
}
}
private void Update()
{
m_timeFPS += Time.deltaTime;
m_counterFPS++;
if (m_timeFPS >= 1f)
{
m_timeFPS -= 1f;
m_fps = m_counterFPS;
m_counterFPS = 0;
}
}
private void OnDestroy()
{
Application.logMessageReceived -= HandleLog;
}
private void OnGUI()
{
GUI.depth = -9999;
GUILayout.Label(" FPS: " + m_fps + "\tMRLE v1.38 + Save/Load v2.3");
GUILayout.Label(m_debugString);
if (SceneManager.GetActiveScene().name == "LE_ExampleDungeonEditorGame" || SceneManager.GetActiveScene().name == "LE_ExampleEditorFirstPerson")
{
GUI.Label(new Rect(100f, Screen.height - 20, 250f, 20f), "<b>Look around with RIGHT MOUSE button</b>");
}
GUI.Box(m_qualityLabelRect, "Quality\n" + QualitySettings.names[QualitySettings.GetQualityLevel()]);
if (GUI.Button(m_qualityUpBtnRect, "Increase"))
{
QualitySettings.IncreaseLevel();
}
if (GUI.Button(m_qualityDownBtnRect, "Decrease"))
{
QualitySettings.DecreaseLevel();
}
}
private void HandleLog(string logString, string stackTrace, LogType type)
{
string text = string.Concat("[", type, "] ", logString, "\n");
if (!logString.StartsWith("LE_LevelEditorMain: Inspector property") && !m_debugString.StartsWith(text))
{
m_debugString += text;
m_linesCount++;
if ((float)m_linesCount > (float)Screen.height / 20f)
{
m_debugString = m_debugString.Substring(m_debugString.IndexOf("\n") + 1);
}
}
}
}
}