Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class DebugScreen : MonoBehaviour {
  7.  
  8. World world;
  9. Text text;
  10.  
  11. float frameRate;
  12. float timer;
  13.  
  14. int halfWorldSizeInVoxels;
  15. int halfWorldSizeInChunks;
  16.  
  17. void Start () {
  18.  
  19. world = GameObject.Find("World").GetComponent<World>();
  20. text = GetComponent<Text>();
  21.  
  22. halfWorldSizeInVoxels = VoxelData.WorldSizeInVoxels / 2;
  23. halfWorldSizeInChunks = VoxelData.WorldSizeInChunks / 2;
  24.  
  25. }
  26.  
  27. void Update () {
  28.  
  29. string debugText = "Development Build";
  30. debugText += "\n";
  31. debugText += frameRate + " fps";
  32. debugText += "\n\n";
  33. 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);
  34. debugText += "\n";
  35. debugText += "Chunk: " + (world.playerChunkCoord.x - halfWorldSizeInChunks) + " / " + (world.playerChunkCoord.z - halfWorldSizeInChunks);
  36.  
  37. text.text = debugText;
  38.  
  39. if (timer > 1f)
  40. {
  41.  
  42. frameRate = (int)(1f / Time.unscaledDeltaTime);
  43. timer = 0;
  44.  
  45. }
  46. else
  47. timer += Time.deltaTime;
  48.  
  49.  
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement