1
0
Fork 0

Add debug mode and singleton

This commit is contained in:
Michaël Lemaire 2020-10-12 23:57:28 +02:00
parent faecd672cd
commit eed40eb026
10 changed files with 115 additions and 0 deletions

9
debug/debug_node2d.gd Normal file
View file

@ -0,0 +1,9 @@
extends Node2D
class_name DebugNode2d, "res://addons/thunderk-basics/debug/debug_node2d.png"
func _ready():
TKDebug.connect("active_changed", self, "_on_debug_active_changed")
_on_debug_active_changed()
func _on_debug_active_changed():
set_visible(TKDebug.active)

BIN
debug/debug_node2d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/debug_node2d.png-9af8296c13fef1491514dd8ffc720d31.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/thunderk-basics/debug/debug_node2d.png"
dest_files=[ "res://.import/debug_node2d.png-9af8296c13fef1491514dd8ffc720d31.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

6
debug/debug_node2d.tscn Normal file
View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/thunderk-basics/debug/debug_node2d.gd" type="Script" id=1]
[node name="debug" type="Node2D"]
script = ExtResource( 1 )

9
debug/debug_node3d.gd Normal file
View file

@ -0,0 +1,9 @@
extends Spatial
class_name DebugNode3d, "res://addons/thunderk-basics/debug/debug_node3d.png"
func _ready():
TKDebug.connect("active_changed", self, "_on_debug_active_changed")
_on_debug_active_changed()
func _on_debug_active_changed():
set_visible(TKDebug.active)

BIN
debug/debug_node3d.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/debug_node3d.png-36a7db45ad9e93eafb387b6f9eba2759.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/thunderk-basics/debug/debug_node3d.png"
dest_files=[ "res://.import/debug_node3d.png-36a7db45ad9e93eafb387b6f9eba2759.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

6
debug/debug_node3d.tscn Normal file
View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/thunderk-basics/debug/debug_node3d.gd" type="Script" id=1]
[node name="debug" type="Spatial"]
script = ExtResource( 1 )

11
debug/singleton.gd Normal file
View file

@ -0,0 +1,11 @@
extends Node
export var active = false
signal active_changed
func _process(delta):
# TODO disable in release builds
if Input.is_action_just_pressed("ui_debug"):
active = not active
emit_signal("active_changed")

View file

@ -1,2 +1,8 @@
tool
extends EditorPlugin
func _enter_tree():
add_autoload_singleton("TKDebug", "res://addons/thunderk-basics/debug/singleton.gd")
func _exit_tree():
remove_autoload_singleton("TKDebug")