ResourceSaver.xml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="ResourceSaver" inherits="Object" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Singleton for saving Godot-specific resource types.
  5. </brief_description>
  6. <description>
  7. Singleton for saving Godot-specific resource types to the filesystem.
  8. It uses the many [ResourceFormatSaver] classes registered in the engine (either built-in or from a plugin) to save engine-specific resource data to text-based (e.g. [code].tres[/code] or [code].tscn[/code]) or binary files (e.g. [code].res[/code] or [code].scn[/code]).
  9. </description>
  10. <tutorials>
  11. </tutorials>
  12. <methods>
  13. <method name="add_resource_format_saver">
  14. <return type="void" />
  15. <argument index="0" name="format_saver" type="ResourceFormatSaver" />
  16. <argument index="1" name="at_front" type="bool" default="false" />
  17. <description>
  18. Registers a new [ResourceFormatSaver]. The ResourceSaver will use the ResourceFormatSaver as described in [method save].
  19. This method is performed implicitly for ResourceFormatSavers written in GDScript (see [ResourceFormatSaver] for more information).
  20. </description>
  21. </method>
  22. <method name="get_recognized_extensions">
  23. <return type="PackedStringArray" />
  24. <argument index="0" name="type" type="Resource" />
  25. <description>
  26. Returns the list of extensions available for saving a resource of a given type.
  27. </description>
  28. </method>
  29. <method name="remove_resource_format_saver">
  30. <return type="void" />
  31. <argument index="0" name="format_saver" type="ResourceFormatSaver" />
  32. <description>
  33. Unregisters the given [ResourceFormatSaver].
  34. </description>
  35. </method>
  36. <method name="save">
  37. <return type="int" enum="Error" />
  38. <argument index="0" name="resource" type="Resource" />
  39. <argument index="1" name="path" type="String" default="&quot;&quot;" />
  40. <argument index="2" name="flags" type="int" enum="ResourceSaver.SaverFlags" default="0" />
  41. <description>
  42. Saves a resource to disk to the given path, using a [ResourceFormatSaver] that recognizes the resource object. If [code]path[/code] is empty, [ResourceSaver] will try to use [member Resource.resource_path].
  43. The [code]flags[/code] bitmask can be specified to customize the save behavior using [enum SaverFlags] flags.
  44. Returns [constant OK] on success.
  45. </description>
  46. </method>
  47. </methods>
  48. <constants>
  49. <constant name="FLAG_NONE" value="0" enum="SaverFlags" is_bitfield="true">
  50. No resource saving option.
  51. </constant>
  52. <constant name="FLAG_RELATIVE_PATHS" value="1" enum="SaverFlags" is_bitfield="true">
  53. Save the resource with a path relative to the scene which uses it.
  54. </constant>
  55. <constant name="FLAG_BUNDLE_RESOURCES" value="2" enum="SaverFlags" is_bitfield="true">
  56. Bundles external resources.
  57. </constant>
  58. <constant name="FLAG_CHANGE_PATH" value="4" enum="SaverFlags" is_bitfield="true">
  59. Changes the [member Resource.resource_path] of the saved resource to match its new location.
  60. </constant>
  61. <constant name="FLAG_OMIT_EDITOR_PROPERTIES" value="8" enum="SaverFlags" is_bitfield="true">
  62. Do not save editor-specific metadata (identified by their [code]__editor[/code] prefix).
  63. </constant>
  64. <constant name="FLAG_SAVE_BIG_ENDIAN" value="16" enum="SaverFlags" is_bitfield="true">
  65. Save as big endian (see [member File.big_endian]).
  66. </constant>
  67. <constant name="FLAG_COMPRESS" value="32" enum="SaverFlags" is_bitfield="true">
  68. Compress the resource on save using [constant File.COMPRESSION_ZSTD]. Only available for binary resource types.
  69. </constant>
  70. <constant name="FLAG_REPLACE_SUBRESOURCE_PATHS" value="64" enum="SaverFlags" is_bitfield="true">
  71. Take over the paths of the saved subresources (see [method Resource.take_over_path]).
  72. </constant>
  73. </constants>
  74. </class>