1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

VisualShader Conversion fails with Embeds

Potentially resolves https://github.com/godotengine/godot/issues/101375

VisualShader now has a has_node_embeds function that runs through it's child nodes to find embedded resources via object properties. Conversion plugin uses this function to catch the error.
This commit is contained in:
Colin O'Rourke
2025-08-06 13:17:19 -07:00
parent 6efa557e9b
commit c4559c02de
5 changed files with 54 additions and 2 deletions

View File

@@ -41,6 +41,7 @@
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/file_system/editor_paths.h"
#include "editor/gui/editor_toaster.h"
#include "editor/inspector/editor_properties.h"
#include "editor/inspector/editor_properties_vector.h"
#include "editor/scene/curve_editor_plugin.h"
@@ -8446,6 +8447,20 @@ bool VisualShaderConversionPlugin::handles(const Ref<Resource> &p_resource) cons
Ref<Resource> VisualShaderConversionPlugin::convert(const Ref<Resource> &p_resource) const {
Ref<VisualShader> vshader = p_resource;
ERR_FAIL_COND_V(vshader.is_null(), Ref<Resource>());
int embed = vshader->has_node_embeds();
EditorToaster *toast = EditorToaster::get_singleton();
if (toast == nullptr) {
ERR_FAIL_COND_V_MSG(embed == 2, Ref<Resource>(), "Cannot convert VisualShader to GDShader because VisualShader has embedded subresources.");
if (embed == 1) {
WARN_PRINT("Visual Shader conversion cannot convert external dependencies. Resource references from Nodes will have to be rebound as ShaderParameters on a Material.");
}
} else if (embed == 2) {
toast->popup_str(TTR("Cannot convert VisualShader to GDShader because VisualShader has embedded subresources."), EditorToaster::SEVERITY_ERROR);
return Ref<Resource>();
} else if (embed == 1) {
toast->popup_str(TTR("Visual Shader conversion cannot convert external dependencies. Resource references from Nodes will have to be rebound as ShaderParameters on a Material."), EditorToaster::SEVERITY_WARNING);
}
Ref<Shader> shader;
shader.instantiate();