Skip to content

Commit

Permalink
fix: add debug cam when play current scene is used
Browse files Browse the repository at this point in the history
  • Loading branch information
yusdacra committed Dec 5, 2024
1 parent 4abda41 commit d931cdc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions addons/debug_camera/scripts/DebugCamAutoload.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ extends Node
var debug_cam_2d = preload("res://addons/debug_camera/scripts/DebugCamera2D.gd")
var debug_cam_3d = preload("res://addons/debug_camera/scripts/DebugCamera3D.gd")

func _ready() -> void:
var cur_scene: Node = get_tree().current_scene
# run if play current scene
if ProjectSettings.get("application/run/main_scene") != cur_scene.scene_file_path:
add_debug_cam(cur_scene)

## call this function after you scene is ready to add the debug camera to it
func add_debug_cam(scene: Node) -> void:
var cam_2d := debug_cam_2d.new()
Expand Down
1 change: 1 addition & 0 deletions addons/debug_camera/scripts/DebugCamera2D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func _unhandled_input(event: InputEvent) -> void:
var cam := main_cam
cam.enabled = !cam.enabled
enabled = !cam.enabled
Loggie.info("toggled 2D debug cam (%s)" % enabled)

if not enabled: return

Expand Down
1 change: 1 addition & 0 deletions addons/debug_camera/scripts/DebugCamera3D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func _unhandled_input(event: InputEvent) -> void:
var cam := main_cam
cam.current = !cam.current
current = !cam.current
Loggie.info("toggled 3D debug cam (%s)" % current)

if not current: return

Expand Down

0 comments on commit d931cdc

Please sign in to comment.