mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-05 02:10:14 +03:00
Support _validate_property()
This commit is contained in:
@@ -23,6 +23,10 @@ func _ready():
|
||||
# Property list.
|
||||
example.property_from_list = Vector3(100, 200, 300)
|
||||
assert_equal(example.property_from_list, Vector3(100, 200, 300))
|
||||
var prop_list = example.get_property_list()
|
||||
for prop_info in prop_list:
|
||||
if prop_info['name'] == 'mouse_filter':
|
||||
assert_equal(prop_info['usage'], PROPERTY_USAGE_NO_EDITOR)
|
||||
|
||||
# Call simple methods.
|
||||
example.simple_func()
|
||||
|
||||
@@ -117,6 +117,14 @@ bool Example::_property_get_revert(const StringName &p_name, Variant &r_property
|
||||
}
|
||||
};
|
||||
|
||||
void Example::_validate_property(PropertyInfo &p_property) const {
|
||||
String name = p_property.name;
|
||||
// Test hiding the "mouse_filter" property from the editor.
|
||||
if (name == "mouse_filter") {
|
||||
p_property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
}
|
||||
|
||||
void Example::_bind_methods() {
|
||||
// Methods.
|
||||
ClassDB::bind_method(D_METHOD("simple_func"), &Example::simple_func);
|
||||
|
||||
@@ -65,6 +65,7 @@ protected:
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
bool _property_can_revert(const StringName &p_name) const;
|
||||
bool _property_get_revert(const StringName &p_name, Variant &r_property) const;
|
||||
void _validate_property(PropertyInfo &p_property) const;
|
||||
|
||||
String _to_string() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user