1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-22 15:06:45 +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

@@ -967,6 +967,37 @@ void VisualShader::set_node_position(Type p_type, int p_id, const Vector2 &p_pos
g->nodes[p_id].position = p_position;
}
// Returns 0 if no embeds, 1 if external embeds, 2 if builtin embeds
int VisualShader::has_node_embeds() const {
bool external_embeds = false;
for (int i = 0; i < TYPE_MAX; i++) {
for (const KeyValue<int, Node> &E : graph[i].nodes) {
List<PropertyInfo> props;
E.value.node->get_property_list(&props);
// For classes that inherit from VisualShaderNode, the class properties start at the 12th, and the last value is always 'script'
for (int j = 12; j < props.size() - 1; j++) {
// VisualShaderNodeCustom cannot have embeds
if (props.get(j).name == "VisualShaderNodeCustom") {
break;
}
// Ref<Resource> properties get classed as type Variant::Object
if (props.get(j).type == Variant::OBJECT) {
Ref<Resource> res = E.value.node->get(props.get(j).name);
if (res.is_valid()) {
if (res->is_built_in()) {
return 2;
} else {
external_embeds = true;
}
}
}
}
}
}
return external_embeds;
}
Vector2 VisualShader::get_node_position(Type p_type, int p_id) const {
ERR_FAIL_INDEX_V(p_type, TYPE_MAX, Vector2());
const Graph *g = &graph[p_type];