Skip to content

Commit

Permalink
debug overlay script
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonkee committed May 24, 2020
1 parent e998426 commit 9b3e00f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions non-shaders/debug_overlay.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
extends CanvasLayer

# Debug overlay by Gonkee - full tutorial https://youtu.be/8Us2cteHbbo

var stats = []

func add_stat(stat_name, object, stat_ref, is_method):
stats.append([stat_name, object, stat_ref, is_method])

func _process(delta):
var label_text = ""

var fps = Engine.get_frames_per_second()
label_text += str("FPS: ", fps)
label_text += "\n"

var mem = OS.get_static_memory_usage()
label_text += str("Static Memory: ", String.humanize_size(mem))
label_text += "\n"

for s in stats:
var value = null

if s[1] and weakref(s[1]).get_ref():
if s[3]:
value = s[1].call(s[2])
else:
value = s[1].get(s[2])
label_text += str(s[0], ": ", value)
label_text += "\n"

$Label.text = label_text

0 comments on commit 9b3e00f

Please sign in to comment.