Add fps and console debugger
This commit is contained in:
8
Assets/Scripts/UI.meta
Normal file
8
Assets/Scripts/UI.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0691df023b36d7645a6dddab388595b7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Scripts/UI/FPSDebugger.cs
Normal file
31
Assets/Scripts/UI/FPSDebugger.cs
Normal 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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/FPSDebugger.cs.meta
Normal file
11
Assets/Scripts/UI/FPSDebugger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58aa27241a836be4fb0b6487c52f6425
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/Scripts/UI/WristConsole.cs
Normal file
50
Assets/Scripts/UI/WristConsole.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/WristConsole.cs.meta
Normal file
11
Assets/Scripts/UI/WristConsole.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8ec37c6213dba1468232fd1fc123f18
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user