class_resourcesaver.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/ResourceSaver.xml.
  6. .. _class_ResourceSaver:
  7. ResourceSaver
  8. =============
  9. **Inherits:** :ref:`Object<class_Object>`
  10. Singleton for saving Godot-specific resource types.
  11. Description
  12. -----------
  13. Singleton for saving Godot-specific resource types to the filesystem.
  14. It uses the many :ref:`ResourceFormatSaver<class_ResourceFormatSaver>` classes registered in the engine (either built-in or from a plugin) to save engine-specific resource data to text-based (e.g. ``.tres`` or ``.tscn``) or binary files (e.g. ``.res`` or ``.scn``).
  15. Methods
  16. -------
  17. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`add_resource_format_saver<class_ResourceSaver_method_add_resource_format_saver>` **(** :ref:`ResourceFormatSaver<class_ResourceFormatSaver>` format_saver, :ref:`bool<class_bool>` at_front=false **)** |
  19. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_recognized_extensions<class_ResourceSaver_method_get_recognized_extensions>` **(** :ref:`Resource<class_Resource>` type **)** |
  21. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`remove_resource_format_saver<class_ResourceSaver_method_remove_resource_format_saver>` **(** :ref:`ResourceFormatSaver<class_ResourceFormatSaver>` format_saver **)** |
  23. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`save<class_ResourceSaver_method_save>` **(** :ref:`String<class_String>` path, :ref:`Resource<class_Resource>` resource, :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` flags=0 **)** |
  25. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. Enumerations
  27. ------------
  28. .. _enum_ResourceSaver_SaverFlags:
  29. .. _class_ResourceSaver_constant_FLAG_NONE:
  30. .. _class_ResourceSaver_constant_FLAG_RELATIVE_PATHS:
  31. .. _class_ResourceSaver_constant_FLAG_BUNDLE_RESOURCES:
  32. .. _class_ResourceSaver_constant_FLAG_CHANGE_PATH:
  33. .. _class_ResourceSaver_constant_FLAG_OMIT_EDITOR_PROPERTIES:
  34. .. _class_ResourceSaver_constant_FLAG_SAVE_BIG_ENDIAN:
  35. .. _class_ResourceSaver_constant_FLAG_COMPRESS:
  36. .. _class_ResourceSaver_constant_FLAG_REPLACE_SUBRESOURCE_PATHS:
  37. flags **SaverFlags**:
  38. - **FLAG_NONE** = **0** --- No resource saving option.
  39. - **FLAG_RELATIVE_PATHS** = **1** --- Save the resource with a path relative to the scene which uses it.
  40. - **FLAG_BUNDLE_RESOURCES** = **2** --- Bundles external resources.
  41. - **FLAG_CHANGE_PATH** = **4** --- Changes the :ref:`Resource.resource_path<class_Resource_property_resource_path>` of the saved resource to match its new location.
  42. - **FLAG_OMIT_EDITOR_PROPERTIES** = **8** --- Do not save editor-specific metadata (identified by their ``__editor`` prefix).
  43. - **FLAG_SAVE_BIG_ENDIAN** = **16** --- Save as big endian (see :ref:`File.big_endian<class_File_property_big_endian>`).
  44. - **FLAG_COMPRESS** = **32** --- Compress the resource on save using :ref:`File.COMPRESSION_ZSTD<class_File_constant_COMPRESSION_ZSTD>`. Only available for binary resource types.
  45. - **FLAG_REPLACE_SUBRESOURCE_PATHS** = **64** --- Take over the paths of the saved subresources (see :ref:`Resource.take_over_path<class_Resource_method_take_over_path>`).
  46. Method Descriptions
  47. -------------------
  48. .. _class_ResourceSaver_method_add_resource_format_saver:
  49. - void **add_resource_format_saver** **(** :ref:`ResourceFormatSaver<class_ResourceFormatSaver>` format_saver, :ref:`bool<class_bool>` at_front=false **)**
  50. Registers a new :ref:`ResourceFormatSaver<class_ResourceFormatSaver>`. The ResourceSaver will use the ResourceFormatSaver as described in :ref:`save<class_ResourceSaver_method_save>`.
  51. This method is performed implicitly for ResourceFormatSavers written in GDScript (see :ref:`ResourceFormatSaver<class_ResourceFormatSaver>` for more information).
  52. ----
  53. .. _class_ResourceSaver_method_get_recognized_extensions:
  54. - :ref:`PackedStringArray<class_PackedStringArray>` **get_recognized_extensions** **(** :ref:`Resource<class_Resource>` type **)**
  55. Returns the list of extensions available for saving a resource of a given type.
  56. ----
  57. .. _class_ResourceSaver_method_remove_resource_format_saver:
  58. - void **remove_resource_format_saver** **(** :ref:`ResourceFormatSaver<class_ResourceFormatSaver>` format_saver **)**
  59. Unregisters the given :ref:`ResourceFormatSaver<class_ResourceFormatSaver>`.
  60. ----
  61. .. _class_ResourceSaver_method_save:
  62. - :ref:`Error<enum_@GlobalScope_Error>` **save** **(** :ref:`String<class_String>` path, :ref:`Resource<class_Resource>` resource, :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` flags=0 **)**
  63. Saves a resource to disk to the given path, using a :ref:`ResourceFormatSaver<class_ResourceFormatSaver>` that recognizes the resource object.
  64. The ``flags`` bitmask can be specified to customize the save behavior using :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` flags.
  65. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success.
  66. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  67. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  68. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  69. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  70. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  71. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`