HeavenStudio/Assets/Scripts/DebugUI.cs

113 lines
3.8 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
2022-03-14 14:21:05 +00:00
namespace HeavenStudio
{
public class DebugUI : MonoBehaviour
{
public GameObject Template;
2022-01-02 14:57:15 +00:00
private int indexL;
private int indexR;
private TMP_Text Title;
private TMP_Text SongPosBeats;
2022-01-02 14:57:15 +00:00
private TMP_Text SecPerBeat;
private TMP_Text SongPos;
private TMP_Text BPM;
2022-01-02 14:57:15 +00:00
private TMP_Text currEvent;
private TMP_Text eventLength;
private TMP_Text eventType;
2022-01-02 14:57:15 +00:00
private TMP_Text currentGame;
private TMP_Text graphicsDeviceName;
private TMP_Text operatingSystem;
private TMP_Text fps;
private void Start()
{
CreateDebugUI(out Title); SetText(Title, $"Heaven Studio {GlobalGameManager.buildTime}");
2022-01-02 14:57:15 +00:00
CreateDebugUI(out SongPosBeats);
CreateDebugUI(out SongPos);
CreateDebugUI(out SecPerBeat);
CreateDebugUI(out BPM);
Separate();
CreateDebugUI(out currEvent);
CreateDebugUI(out eventLength);
CreateDebugUI(out eventType);
CreateDebugUI(out currentGame);
CreateDebugUI(out operatingSystem, true); SetText(operatingSystem, SystemInfo.operatingSystem);
CreateDebugUI(out graphicsDeviceName, true); SetText(graphicsDeviceName, SystemInfo.graphicsDeviceName);
CreateDebugUI(out fps, true);
2022-01-03 22:42:43 +00:00
transform.GetChild(0).GetComponent<Canvas>().worldCamera = GameManager.instance.CursorCam;
}
private void Update()
{
2022-01-02 14:57:15 +00:00
SetText(SongPosBeats, $"Song Position In Beats: {Conductor.instance.songPositionInBeats}");
SetText(SongPos, $"Song Position: {Conductor.instance.songPosition}");
SetText(BPM, $"BPM: {Conductor.instance.songBpm}");
SetText(fps, $"FPS: {1.0f / Time.smoothDeltaTime}");
SetText(SecPerBeat, $"Seconds Per Beat: {Conductor.instance.secPerBeat}");
SetText(currentGame, $"Current Game: {GameManager.instance.currentGame}");
int minus = 0;
2021-12-25 06:22:09 +00:00
if (GameManager.instance.Beatmap.entities.Count > 0)
{
2022-01-02 14:57:15 +00:00
if (GameManager.instance.currentEvent - 1 >= 0) minus = 1;
SetText(currEvent, $"CurrentEvent: {GameManager.instance.Beatmap.entities[GameManager.instance.currentEvent - minus].datamodel}");
SetText(eventLength, $"Event Length: {GameManager.instance.Beatmap.entities[GameManager.instance.currentEvent - minus].length}");
}
}
private void CreateDebugUI(out TMP_Text t, bool right = false)
{
GameObject debug = Instantiate(Template, Template.transform.parent);
debug.SetActive(true);
if (right)
{
debug.transform.localPosition = new Vector3(322.69f, Template.transform.localPosition.y - 34f * indexR);
debug.GetComponent<TMP_Text>().alignment = TextAlignmentOptions.Right;
debug.transform.GetChild(0).GetComponent<TMP_Text>().alignment = TextAlignmentOptions.Right;
indexR++;
}
else
{
2022-01-02 14:57:15 +00:00
debug.transform.localPosition = new Vector3(Template.transform.localPosition.x, Template.transform.localPosition.y - 34f * indexL);
indexL++;
}
2022-01-02 14:57:15 +00:00
t = debug.transform.GetChild(0).GetComponent<TMP_Text>();
}
private void Separate(bool right = false)
{
if (right)
indexR++;
else
indexL++;
}
private void SetText(TMP_Text t, string text)
{
t.transform.parent.GetComponent<TMP_Text>().text = $"<mark=#3d3d3d padding=\"44.9301, 44.9301, 44.9301, 44.9301\">{text}</mark>";
t.text = text;
}
}
}