summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorYuri Sizov <11782833+YuriSizov@users.noreply.github.com>2022-08-19 20:41:41 +0300
committerGitHub <noreply@github.com>2022-08-19 20:41:41 +0300
commit7895a66cf21348920298c83968d6c5399d8339cf (patch)
tree6b74c4e351c6dfa39c3d56c08a4c58613900141d /scene/resources
parent35cfaafda8073f700c9d2fe42a43d3d81eaaea67 (diff)
parent980f5f32f492ad7e55915f37a6104789d43c89e1 (diff)
Merge pull request #64334 from YuriSizov/core-bind-property-revert-methods
Make `property_*_revert` methods multilevel and expose them for scripting
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/material.cpp12
-rw-r--r--scene/resources/material.h4
2 files changed, 7 insertions, 9 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 88bc01fb25..5d887dae17 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -297,7 +297,7 @@ void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
-bool ShaderMaterial::property_can_revert(const String &p_name) {
+bool ShaderMaterial::_property_can_revert(const StringName &p_name) const {
if (shader.is_valid()) {
StringName pr = shader->remap_uniform(p_name);
if (pr) {
@@ -310,15 +310,15 @@ bool ShaderMaterial::property_can_revert(const String &p_name) {
return false;
}
-Variant ShaderMaterial::property_get_revert(const String &p_name) {
- Variant r_ret;
+bool ShaderMaterial::_property_get_revert(const StringName &p_name, Variant &r_property) const {
if (shader.is_valid()) {
StringName pr = shader->remap_uniform(p_name);
if (pr) {
- r_ret = RenderingServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr);
+ r_property = RenderingServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr);
+ return true;
}
}
- return r_ret;
+ return false;
}
void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
@@ -386,8 +386,6 @@ void ShaderMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_shader"), &ShaderMaterial::get_shader);
ClassDB::bind_method(D_METHOD("set_shader_uniform", "param", "value"), &ShaderMaterial::set_shader_uniform);
ClassDB::bind_method(D_METHOD("get_shader_uniform", "param"), &ShaderMaterial::get_shader_uniform);
- ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ShaderMaterial::property_can_revert);
- ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ShaderMaterial::property_get_revert);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shader", PROPERTY_HINT_RESOURCE_TYPE, "Shader"), "set_shader", "get_shader");
}
diff --git a/scene/resources/material.h b/scene/resources/material.h
index ca5b17dd07..6049671582 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -99,8 +99,8 @@ protected:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
- bool property_can_revert(const String &p_name);
- Variant property_get_revert(const String &p_name);
+ bool _property_can_revert(const StringName &p_name) const;
+ bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
static void _bind_methods();