1
0
Fork 0

Fix default environment project setting and loading

This commit is contained in:
ydeltastar 2024-11-26 23:16:11 -03:00
parent bbc54692c0
commit 8793764ba6
No known key found for this signature in database
GPG Key ID: 98ED8D8EB56C2921
1 changed files with 30 additions and 17 deletions

View File

@ -608,9 +608,21 @@ bool SceneTree::process(double p_time) {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
#ifndef _3D_DISABLED #ifndef _3D_DISABLED
if (Engine::get_singleton()->is_editor_hint()) { if (Engine::get_singleton()->is_editor_hint()) {
//simple hack to reload fallback environment if it changed from editor
String env_path = GLOBAL_GET(SNAME("rendering/environment/defaults/default_environment")); String env_path = GLOBAL_GET(SNAME("rendering/environment/defaults/default_environment"));
env_path = env_path.strip_edges(); //user may have added a space or two env_path = env_path.strip_edges(); // User may have added a space or two.
bool can_load = true;
if (env_path.begins_with("uid://")) {
// If an uid path, ensure it is mapped to a resource which could not be
// the case if the editor is still scanning the filesystem.
ResourceUID::ID id = ResourceUID::get_singleton()->text_to_id(env_path);
can_load = ResourceUID::get_singleton()->has_id(id);
if (can_load) {
env_path = ResourceUID::get_singleton()->get_id_path(id);
}
}
if (can_load) {
String cpath; String cpath;
Ref<Environment> fallback = get_root()->get_world_3d()->get_fallback_environment(); Ref<Environment> fallback = get_root()->get_world_3d()->get_fallback_environment();
if (fallback.is_valid()) { if (fallback.is_valid()) {
@ -629,6 +641,7 @@ bool SceneTree::process(double p_time) {
get_root()->get_world_3d()->set_fallback_environment(fallback); get_root()->get_world_3d()->set_fallback_environment(fallback);
} }
} }
}
#endif // _3D_DISABLED #endif // _3D_DISABLED
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED