Don't open VisualShaders in the text shader editor, and don't support saving them with the "shader" extension.
This commit is contained in:
parent
06c8b5a4ff
commit
f5c7d64492
@ -426,7 +426,7 @@ void ShaderEditor::ensure_select_current() {
|
|||||||
|
|
||||||
void ShaderEditor::edit(const Ref<Shader> &p_shader) {
|
void ShaderEditor::edit(const Ref<Shader> &p_shader) {
|
||||||
|
|
||||||
if (p_shader.is_null())
|
if (p_shader.is_null() || !p_shader->is_text_shader())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
shader = p_shader;
|
shader = p_shader;
|
||||||
@ -606,7 +606,7 @@ void ShaderEditorPlugin::edit(Object *p_object) {
|
|||||||
bool ShaderEditorPlugin::handles(Object *p_object) const {
|
bool ShaderEditorPlugin::handles(Object *p_object) const {
|
||||||
|
|
||||||
Shader *shader = Object::cast_to<Shader>(p_object);
|
Shader *shader = Object::cast_to<Shader>(p_object);
|
||||||
return shader != NULL;
|
return shader != NULL && shader->is_text_shader();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderEditorPlugin::make_visible(bool p_visible) {
|
void ShaderEditorPlugin::make_visible(bool p_visible) {
|
||||||
|
@ -126,6 +126,11 @@ void Shader::get_default_texture_param_list(List<StringName> *r_textures) const
|
|||||||
r_textures->push_back(E->key());
|
r_textures->push_back(E->key());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Shader::is_text_shader() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Shader::has_param(const StringName &p_param) const {
|
bool Shader::has_param(const StringName &p_param) const {
|
||||||
|
|
||||||
return params_cache.has(p_param);
|
return params_cache.has(p_param);
|
||||||
@ -235,8 +240,10 @@ Error ResourceFormatSaverShader::save(const String &p_path, const RES &p_resourc
|
|||||||
|
|
||||||
void ResourceFormatSaverShader::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
|
void ResourceFormatSaverShader::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
|
||||||
|
|
||||||
if (Object::cast_to<Shader>(*p_resource)) {
|
if (const Shader *shader = Object::cast_to<Shader>(*p_resource)) {
|
||||||
p_extensions->push_back("shader");
|
if (shader->is_text_shader()) {
|
||||||
|
p_extensions->push_back("shader");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool ResourceFormatSaverShader::recognize(const RES &p_resource) const {
|
bool ResourceFormatSaverShader::recognize(const RES &p_resource) const {
|
||||||
|
@ -79,6 +79,8 @@ public:
|
|||||||
Ref<Texture> get_default_texture_param(const StringName &p_param) const;
|
Ref<Texture> get_default_texture_param(const StringName &p_param) const;
|
||||||
void get_default_texture_param_list(List<StringName> *r_textures) const;
|
void get_default_texture_param_list(List<StringName> *r_textures) const;
|
||||||
|
|
||||||
|
virtual bool is_text_shader() const;
|
||||||
|
|
||||||
_FORCE_INLINE_ StringName remap_param(const StringName &p_param) const {
|
_FORCE_INLINE_ StringName remap_param(const StringName &p_param) const {
|
||||||
if (params_cache_dirty)
|
if (params_cache_dirty)
|
||||||
get_param_list(NULL);
|
get_param_list(NULL);
|
||||||
|
@ -414,6 +414,10 @@ Shader::Mode VisualShader::get_mode() const {
|
|||||||
return shader_mode;
|
return shader_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VisualShader::is_text_shader() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port, Vector<DefaultTextureParam> &default_tex_params) const {
|
String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port, Vector<DefaultTextureParam> &default_tex_params) const {
|
||||||
|
|
||||||
Ref<VisualShaderNode> node = get_node(p_type, p_node);
|
Ref<VisualShaderNode> node = get_node(p_type, p_node);
|
||||||
|
@ -141,6 +141,8 @@ public:
|
|||||||
void set_mode(Mode p_mode);
|
void set_mode(Mode p_mode);
|
||||||
virtual Mode get_mode() const;
|
virtual Mode get_mode() const;
|
||||||
|
|
||||||
|
virtual bool is_text_shader() const;
|
||||||
|
|
||||||
void set_graph_offset(const Vector2 &p_offset);
|
void set_graph_offset(const Vector2 &p_offset);
|
||||||
Vector2 get_graph_offset() const;
|
Vector2 get_graph_offset() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user