Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class DebugScreen : MonoBehaviour {
- World world;
- Text text;
- float frameRate;
- float timer;
- int halfWorldSizeInVoxels;
- int halfWorldSizeInChunks;
- void Start () {
- world = GameObject.Find("World").GetComponent<World>();
- text = GetComponent<Text>();
- halfWorldSizeInVoxels = VoxelData.WorldSizeInVoxels / 2;
- halfWorldSizeInChunks = VoxelData.WorldSizeInChunks / 2;
- }
- void Update () {
- string debugText = "Development Build";
- debugText += "\n";
- debugText += frameRate + " fps";
- debugText += "\n\n";
- debugText += "XYZ: " + (Mathf.FloorToInt(world.player.transform.position.x) - halfWorldSizeInVoxels) + " / " + Mathf.FloorToInt(world.player.transform.position.y) + " / " + (Mathf.FloorToInt(world.player.transform.position.z) - halfWorldSizeInVoxels);
- debugText += "\n";
- debugText += "Chunk: " + (world.playerChunkCoord.x - halfWorldSizeInChunks) + " / " + (world.playerChunkCoord.z - halfWorldSizeInChunks);
- text.text = debugText;
- if (timer > 1f)
- {
- frameRate = (int)(1f / Time.unscaledDeltaTime);
- timer = 0;
- }
- else
- timer += Time.deltaTime;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement