class_resourcesaver.rst 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the ResourceSaver.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_ResourceSaver:
  6. ResourceSaver
  7. =============
  8. **Inherits:** :ref:`Object<class_Object>`
  9. Singleton for saving Godot-specific resource types.
  10. Description
  11. -----------
  12. Singleton for saving Godot-specific resource types to the filesystem.
  13. 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``).
  14. Methods
  15. -------
  16. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_recognized_extensions<class_ResourceSaver_method_get_recognized_extensions>` **(** :ref:`Resource<class_Resource>` type **)** |
  18. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`save<class_ResourceSaver_method_save>` **(** :ref:`String<class_String>` path, :ref:`Resource<class_Resource>` resource, :ref:`int<class_int>` flags=0 **)** |
  20. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. Enumerations
  22. ------------
  23. .. _enum_ResourceSaver_SaverFlags:
  24. .. _class_ResourceSaver_constant_FLAG_NONE:
  25. .. _class_ResourceSaver_constant_FLAG_RELATIVE_PATHS:
  26. .. _class_ResourceSaver_constant_FLAG_BUNDLE_RESOURCES:
  27. .. _class_ResourceSaver_constant_FLAG_CHANGE_PATH:
  28. .. _class_ResourceSaver_constant_FLAG_OMIT_EDITOR_PROPERTIES:
  29. .. _class_ResourceSaver_constant_FLAG_SAVE_BIG_ENDIAN:
  30. .. _class_ResourceSaver_constant_FLAG_COMPRESS:
  31. .. _class_ResourceSaver_constant_FLAG_REPLACE_SUBRESOURCE_PATHS:
  32. enum **SaverFlags**:
  33. - **FLAG_NONE** = **0** --- No resource saving option.
  34. - **FLAG_RELATIVE_PATHS** = **1** --- Save the resource with a path relative to the scene which uses it.
  35. - **FLAG_BUNDLE_RESOURCES** = **2** --- Bundles external resources.
  36. - **FLAG_CHANGE_PATH** = **4** --- Changes the :ref:`Resource.resource_path<class_Resource_property_resource_path>` of the saved resource to match its new location.
  37. - **FLAG_OMIT_EDITOR_PROPERTIES** = **8** --- Do not save editor-specific metadata (identified by their ``__editor`` prefix).
  38. - **FLAG_SAVE_BIG_ENDIAN** = **16** --- Save as big endian (see :ref:`File.big_endian<class_File_property_big_endian>`).
  39. - **FLAG_COMPRESS** = **32** --- Compress the resource on save using :ref:`File.COMPRESSION_ZSTD<class_File_constant_COMPRESSION_ZSTD>`. Only available for binary resource types.
  40. - **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>`).
  41. Method Descriptions
  42. -------------------
  43. .. _class_ResourceSaver_method_get_recognized_extensions:
  44. - :ref:`PackedStringArray<class_PackedStringArray>` **get_recognized_extensions** **(** :ref:`Resource<class_Resource>` type **)**
  45. Returns the list of extensions available for saving a resource of a given type.
  46. ----
  47. .. _class_ResourceSaver_method_save:
  48. - :ref:`Error<enum_@GlobalScope_Error>` **save** **(** :ref:`String<class_String>` path, :ref:`Resource<class_Resource>` resource, :ref:`int<class_int>` flags=0 **)**
  49. Saves a resource to disk to the given path, using a :ref:`ResourceFormatSaver<class_ResourceFormatSaver>` that recognizes the resource object.
  50. The ``flags`` bitmask can be specified to customize the save behavior using :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` flags.
  51. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success.
  52. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  53. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  54. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  55. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  56. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  57. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`