Add fps and console debugger

This commit is contained in:
2024-08-07 16:58:22 +02:00
parent 2e6f3765f1
commit 5281883fa8
86 changed files with 15270 additions and 3 deletions

8
Assets/Scripts/UI.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0691df023b36d7645a6dddab388595b7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class FPSDebugger : MonoBehaviour
{
[SerializeField]
TextMeshProUGUI fpsText;
private int refreshRate = 10;
private int frameCounter = 0;
private float totalTime = 0;
void Update()
{
if (frameCounter == refreshRate)
{
var averageFps = 1.0 / (totalTime / refreshRate);
fpsText.text = averageFps.ToString("F1");
frameCounter = 0;
totalTime = 0;
} else
{
totalTime += Time.deltaTime;
frameCounter++;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 58aa27241a836be4fb0b6487c52f6425
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class WristConsole : MonoBehaviour
{
[SerializeField]
private TextMeshProUGUI consoleText;
[SerializeField]
private GameObject anchor;
string output = "";
private void OnEnable()
{
Application.logMessageReceived += logMessageReceived;
}
private void OnDisable()
{
Application.logMessageReceived -= logMessageReceived;
}
private void logMessageReceived(string log, string stack, LogType type)
{
output = log + "\n" + output;
consoleText.text = output;
}
private void Update()
{
Vector3 fakeForward = anchor.transform.forward;
fakeForward.y = 0.0f;
fakeForward.Normalize();
transform.position = Vector3.Lerp(
transform.position,
new Vector3(
anchor.transform.position.x,
anchor.transform.position.y - 1.0f,
anchor.transform.position.z)
+ fakeForward * 1.5f,
Time.deltaTime * 20.0f);
transform.rotation = Quaternion.LookRotation(transform.position - anchor.transform.position);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a8ec37c6213dba1468232fd1fc123f18
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: