using System; using System.Diagnostics; using Artngame.SKYMASTER.PlanetCreator.Atmosphere; using UnityEngine; using UnityEngine.Profiling; namespace Artngame.SKYMASTER.PlanetCreator { public class DebugGui : MonoBehaviour { [SerializeField] private AtmosphericScatter scatter; [SerializeField] private FlyCameraA camera; [SerializeField] private Transform orientationGizmo; [SerializeField] private PlanetCreator planetCreator; private float deltaTime; private bool showOrientationGizmo; private bool showDetailedInfo; private void Start() { orientationGizmo.gameObject.SetActive(showOrientationGizmo); } private void OnGUI() { int height = Screen.height; GUIStyle gUIStyle = new GUIStyle(); gUIStyle.alignment = TextAnchor.UpperLeft; gUIStyle.fontSize = height * 2 / 100; gUIStyle.normal.textColor = Color.white; float num = deltaTime * 1000f; float num2 = 1f / deltaTime; GUILayout.Label($"{num:0.0} ms ({num2:0.} fps)", gUIStyle); GUILayout.Label("Speed: " + camera.speedMultiply, gUIStyle); showDetailedInfo = GUILayout.Toggle(showDetailedInfo, "Show Detailed Info"); showOrientationGizmo = GUILayout.Toggle(showOrientationGizmo, "Show Orientation"); QualitySettings.vSyncCount = (GUILayout.Toggle(QualitySettings.vSyncCount == 1, "Enable VSync") ? 1 : 0); GUILayout.BeginHorizontal(); GUILayout.Label("Downsample"); scatter.downscale = (int)GUILayout.HorizontalSlider(scatter.downscale, 1f, 10f, GUILayout.Width(100f)); GUILayout.EndHorizontal(); if (showDetailedInfo) { Process.GetCurrentProcess(); GUILayout.Label($"Mesh Pool Size: {planetCreator.MeshPoolSize}"); GUILayout.Label($"Split Pool Size: {planetCreator.SplitPoolSize}"); GUILayout.Label($"Mono Memory Usage: {(double)Profiler.GetMonoUsedSizeLong() * 1E-06:F0}mb"); GUILayout.Label($"Process Memory Usage: {(double)GC.GetTotalMemory(forceFullCollection: false) * 1E-06:F0}mb"); } if (GUI.changed) { orientationGizmo.gameObject.SetActive(showOrientationGizmo); } } private void Update() { deltaTime += (Time.deltaTime - deltaTime) * 0.1f; orientationGizmo.transform.rotation = Quaternion.identity; } } }