1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

C#: Ensure we only create one CSharpScript per type

Previously, for each scripts class instance that was created from code
rather than by the engine, we were constructing, configuring and
assigning a new CSharpScript.
This has changed now and we make sure there's only one CSharpScript
associated to each type.
This commit is contained in:
Ignacio Roldán Etcheverry
2022-02-27 21:57:36 +01:00
parent 92503ae8db
commit 67db89988d
9 changed files with 140 additions and 135 deletions

View File

@@ -134,7 +134,6 @@ private:
// Do not use unless you know what you are doing
static void update_script_class_info(Ref<CSharpScript> p_script);
static void initialize_for_managed_type(Ref<CSharpScript> p_script);
protected:
static void _bind_methods();
@@ -144,6 +143,8 @@ protected:
void _get_property_list(List<PropertyInfo> *p_properties) const;
public:
static void reload_registered_script(Ref<CSharpScript> p_script);
bool can_instantiate() const override;
StringName get_instance_base_type() const override;
ScriptInstance *instance_create(Object *p_this) override;
@@ -460,7 +461,7 @@ public:
bool setup_csharp_script_binding(CSharpScriptBinding &r_script_binding, Object *p_object);
static void tie_native_managed_to_unmanaged(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged, const StringName *p_native_name, bool p_ref_counted);
static void tie_user_managed_to_unmanaged(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged, CSharpScript *p_script, bool p_ref_counted);
static void tie_user_managed_to_unmanaged(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged, Ref<CSharpScript> *p_script, bool p_ref_counted);
static void tie_managed_to_unmanaged_with_pre_setup(GCHandleIntPtr p_gchandle_intptr, Object *p_unmanaged);
#warning TODO