GDScript: Deprecate inst_to_dict() and dict_to_inst() functions

This commit is contained in:
Danil Alexeev
2025-01-03 21:17:06 +03:00
parent bdf625bd54
commit 07f8935c69
2 changed files with 8 additions and 5 deletions

View File

@ -74,7 +74,7 @@
[/codeblock]
</description>
</method>
<method name="dict_to_inst">
<method name="dict_to_inst" deprecated="Consider using [method JSON.to_native] or [method Object.get_property_list] instead.">
<return type="Object" />
<param index="0" name="dictionary" type="Dictionary" />
<description>
@ -103,12 +103,11 @@
[b]Note:[/b] Calling this function from a [Thread] is not supported. Doing so will return an empty array.
</description>
</method>
<method name="inst_to_dict">
<method name="inst_to_dict" deprecated="Consider using [method JSON.from_native] or [method Object.get_property_list] instead.">
<return type="Dictionary" />
<param index="0" name="instance" type="Object" />
<description>
Returns the passed [param instance] converted to a Dictionary. Can be useful for serializing.
[b]Note:[/b] Cannot be used to serialize objects with built-in scripts attached or objects allocated within built-in scripts.
[codeblock]
var foo = "bar"
func _ready():
@ -121,6 +120,8 @@
[@subpath, @path, foo]
[, res://test.gd, bar]
[/codeblock]
[b]Note:[/b] This function can only be used to serialize objects with an attached [GDScript] stored in a separate file. Objects without an attached script, with a script written in another language, or with a built-in script are not supported.
[b]Note:[/b] This function is not recursive, which means that nested objects will not be represented as dictionaries. Also, properties passed by reference ([Object], [Dictionary], [Array], and packed arrays) are copied by reference, not duplicated.
</description>
</method>
<method name="is_instance_of">