You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently the Scene Runner does not support loading scenes by uid:// paths.
If a uid:// path is used, the GdUnitSceneRunner: Can't load scene by given resource path... branch from the following snippet of the Scene Runner initializer is executed:
# handle scene loading by resource pathif typeof(p_scene) == TYPE_STRING:if !FileAccess.file_exists(p_scene):ifnot p_hide_push_errors:# *** uid:// paths fall into this error ***
push_error("GdUnitSceneRunner: Can't load scene by given resource path: '%s'. The resource not exists." % p_scene)
returnif !str(p_scene).ends_with("tscn"):ifnot p_hide_push_errors:
push_error("GdUnitSceneRunner: The given resource: '%s'. is not a scene." % p_scene)
return
_current_scene = load(p_scene).instantiate()
_scene_auto_free =true
Describe the solution you'd like
I would like to add support for uid:// paths to the Scene Runner initializer. These paths can be preferable over res:// paths since it is possible to rename project files without invalidating hard coded path references.
Describe alternatives you've considered
In GDScript, to get around this limitation, you can load the scene resource via the uid:// path, then pass that to the initializer instead. However, in C#, the ISceneRunner currently only accepts a string path as an argument. Therefore, adding uid:// path support would be especially useful for C#.
In C#, you can get around this issue by doing the following, but this requires some extra steps:
# Why
This PR adds `uid://` path support to the Scene Runner per #421.
# What
* Changed the file path exists check from using `FileAccess.file_exists`
to `ResourceLoader.exists` since the Resource Loader method works for
`uid://` paths.
* Added a check for the binary scene extension `.scn`.
* Added a new test for the `uid://` path. The test was copied from
`test_runner_by_resource_path()` but uses the `uid://` path for the test
scene instead.
Closes#421
Is your feature request related to a problem? Please describe.
Currently the Scene Runner does not support loading scenes by
uid://
paths.If a
uid://
path is used, theGdUnitSceneRunner: Can't load scene by given resource path...
branch from the following snippet of the Scene Runner initializer is executed:Describe the solution you'd like
I would like to add support for
uid://
paths to the Scene Runner initializer. These paths can be preferable overres://
paths since it is possible to rename project files without invalidating hard coded path references.Describe alternatives you've considered
In GDScript, to get around this limitation, you can load the scene resource via the
uid://
path, then pass that to the initializer instead. However, in C#, theISceneRunner
currently only accepts a string path as an argument. Therefore, addinguid://
path support would be especially useful for C#.In C#, you can get around this issue by doing the following, but this requires some extra steps:
Additional context
I am willing to implement this feature and will submit a follow up pull request.
The text was updated successfully, but these errors were encountered: