Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a specific error when creating a ViewportTexture in a Texture2D node #85723

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include "scene/resources/font.h"
#include "scene/resources/mesh.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/visual_shader_nodes.h"

///////////////////// Nil /////////////////////////

Expand Down Expand Up @@ -3196,6 +3197,13 @@ void EditorPropertyResource::_resource_changed(const Ref<Resource> &p_resource)
Ref<ViewportTexture> vpt = p_resource;
if (vpt.is_valid()) {
r = Object::cast_to<Resource>(get_edited_object());
if (Object::cast_to<VisualShaderNodeTexture>(r)) {
EditorNode::get_singleton()->show_warning(TTR("Can't create a ViewportTexture in a Texture2D node because the texture will not be bound to a scene.\nUse a Texture2DParameter node instead and set the texture in the \"Shader Parameters\" tab."));
emit_changed(get_edited_property(), Ref<Resource>());
update_property();
return;
}

if (r && r->get_path().is_resource_file()) {
EditorNode::get_singleton()->show_warning(TTR("Can't create a ViewportTexture on resources saved as a file.\nResource needs to belong to a scene."));
emit_changed(get_edited_property(), Ref<Resource>());
Expand Down