Skip to content

Commit

Permalink
Report staging load errors (#518)
Browse files Browse the repository at this point in the history
Add reporting of stage load errors by writing to log-file, writing to console, breaking in the debugger, and quitting with a non-zero exit code.
  • Loading branch information
Malcolmnixon committed Oct 8, 2023
1 parent b87b783 commit 8d77446
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions VERSIONS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 4.3.0
- Upgraded project to Godot 4.1 as the new minimum version.
- Added reporting of stage load errors.

# 4.2.1
- Fixed snap-zones showing highlight when disabled.
Expand Down
15 changes: 14 additions & 1 deletion addons/godot-xr-tools/staging/staging.gd
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,28 @@ func load_scene(p_scene_path : String, user_data = null) -> void:
ResourceLoader.load_threaded_request(p_scene_path)

# Loop waiting for the scene to load
var res : ResourceLoader.ThreadLoadStatus
while true:
var progress := []
var res := ResourceLoader.load_threaded_get_status(p_scene_path, progress)
res = ResourceLoader.load_threaded_get_status(p_scene_path, progress)
if res != ResourceLoader.THREAD_LOAD_IN_PROGRESS:
break;

$LoadingScreen.progress = progress[0]
await get_tree().create_timer(0.1).timeout

# Handle load error
if res != ResourceLoader.THREAD_LOAD_LOADED:
# Report the error to the log and console
push_error("Error ", res, " loading resource ", p_scene_path)

# Halt if running in the debugger
# gdlint:ignore=expression-not-assigned
breakpoint

# Terminate with a non-zero error code to indicate failure
get_tree().quit(1)

# Get the loaded scene
new_scene = ResourceLoader.load_threaded_get(p_scene_path)

Expand Down

0 comments on commit 8d77446

Please sign in to comment.