diff options
author | kobewi <kobewi4e@gmail.com> | 2023-04-07 14:01:57 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2023-08-28 15:18:48 +0200 |
commit | 67db4693ebdc972eae2395fecd39dc174045b980 (patch) | |
tree | 54bd2a4097fd2b744459e45f3f14a66895a46cb2 /modules/mono/csharp_script.cpp | |
parent | 713bfaf5eac1eb8a770e5ee825db29de99f3d0f7 (diff) | |
download | redot-engine-67db4693ebdc972eae2395fecd39dc174045b980.tar.gz |
Expose _validate_property() for scripting
Diffstat (limited to 'modules/mono/csharp_script.cpp')
-rw-r--r-- | modules/mono/csharp_script.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 2971706c75..1fcb2791d9 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1656,7 +1656,8 @@ void CSharpInstance::get_property_list(List<PropertyInfo> *p_properties) const { } } - for (const PropertyInfo &prop : props) { + for (PropertyInfo &prop : props) { + validate_property(prop); p_properties->push_back(prop); } } @@ -1694,6 +1695,24 @@ bool CSharpInstance::property_can_revert(const StringName &p_name) const { return (bool)ret; } +void CSharpInstance::validate_property(PropertyInfo &p_property) const { + ERR_FAIL_COND(!script.is_valid()); + + Variant property_arg = (Dictionary)p_property; + const Variant *args[1] = { &property_arg }; + + Variant ret; + Callable::CallError call_error; + GDMonoCache::managed_callbacks.CSharpInstanceBridge_Call( + gchandle.get_intptr(), &SNAME("_validate_property"), args, 1, &call_error, &ret); + + if (call_error.error != Callable::CallError::CALL_OK) { + return; + } + + p_property = PropertyInfo::from_dict(property_arg); +} + bool CSharpInstance::property_get_revert(const StringName &p_name, Variant &r_ret) const { ERR_FAIL_COND_V(!script.is_valid(), false); |