Archived
Private
Public Access
1
0
This repository has been archived on 2026-02-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ProjectBackup/Unity/Minecraft/Assets/Scripts/UI/DebugScreen.cs
2022-11-12 13:10:03 +01:00

35 lines
1.2 KiB
C#

using Terrain;
using UnityEngine;
using UnityEngine.UI;
namespace UI {
public class DebugScreen : MonoBehaviour {
public World world;
public Text text;
private float _frameRate;
private float _timer;
private void Update() {
string debugText = "Minecraft Clone (Tutorial from b3agz)\n";
debugText += $"FPS: {_frameRate}\n\n";
debugText += $"XYZ: {Mathf.FloorToInt(world.player.transform.position.x)} : {Mathf.FloorToInt(world.player.transform.position.y)} : {Mathf.FloorToInt(world.player.transform.position.z)}\n";
debugText += $"Chunk: {world.lastPlayerChunk.x} : {world.lastPlayerChunk.y}\n";
debugText += $"Biome: {GetPlayerBiome()}";
text.text = debugText;
if (_timer > 1.0f) {
_frameRate = (int)(1.0f / Time.unscaledDeltaTime);
_timer = 0;
}
_timer += Time.deltaTime;
}
private string GetPlayerBiome() {
int index = world.BlockBiomes[Mathf.FloorToInt(world.player.position.x), Mathf.FloorToInt(world.player.position.z)];
return world.biomes[index].biomeName;
}
}
}