class_resourcesaver.rst 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.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. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Singleton for saving Godot-specific resource types.
  13. Methods
  14. -------
  15. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_recognized_extensions<class_ResourceSaver_method_get_recognized_extensions>` **(** :ref:`Resource<class_Resource>` type **)** |
  17. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :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 **)** |
  19. +-----------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. Enumerations
  21. ------------
  22. .. _enum_ResourceSaver_SaverFlags:
  23. .. _class_ResourceSaver_constant_FLAG_RELATIVE_PATHS:
  24. .. _class_ResourceSaver_constant_FLAG_BUNDLE_RESOURCES:
  25. .. _class_ResourceSaver_constant_FLAG_CHANGE_PATH:
  26. .. _class_ResourceSaver_constant_FLAG_OMIT_EDITOR_PROPERTIES:
  27. .. _class_ResourceSaver_constant_FLAG_SAVE_BIG_ENDIAN:
  28. .. _class_ResourceSaver_constant_FLAG_COMPRESS:
  29. .. _class_ResourceSaver_constant_FLAG_REPLACE_SUBRESOURCE_PATHS:
  30. enum **SaverFlags**:
  31. - **FLAG_RELATIVE_PATHS** = **1** --- Save the resource with a path relative to the scene which uses it.
  32. - **FLAG_BUNDLE_RESOURCES** = **2** --- Bundles external resources.
  33. - **FLAG_CHANGE_PATH** = **4** --- Change the :ref:`Resource.resource_path<class_Resource_property_resource_path>` of the saved resource to match its new location.
  34. - **FLAG_OMIT_EDITOR_PROPERTIES** = **8** --- Do not save editor-specific metadata (identified by their ``__editor`` prefix).
  35. - **FLAG_SAVE_BIG_ENDIAN** = **16** --- Save as big endian (see :ref:`File.endian_swap<class_File_property_endian_swap>`).
  36. - **FLAG_COMPRESS** = **32** --- Compress the resource on save using :ref:`File.COMPRESSION_ZSTD<class_File_constant_COMPRESSION_ZSTD>`. Only available for binary resource types.
  37. - **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>`).
  38. Description
  39. -----------
  40. Singleton for saving Godot-specific resource types to the filesystem.
  41. 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``).
  42. Method Descriptions
  43. -------------------
  44. .. _class_ResourceSaver_method_get_recognized_extensions:
  45. - :ref:`PoolStringArray<class_PoolStringArray>` **get_recognized_extensions** **(** :ref:`Resource<class_Resource>` type **)**
  46. Returns the list of extensions available for saving a resource of a given type.
  47. ----
  48. .. _class_ResourceSaver_method_save:
  49. - :ref:`Error<enum_@GlobalScope_Error>` **save** **(** :ref:`String<class_String>` path, :ref:`Resource<class_Resource>` resource, :ref:`int<class_int>` flags=0 **)**
  50. Saves a resource to disk to the given path, using a :ref:`ResourceFormatSaver<class_ResourceFormatSaver>` that recognizes the resource object.
  51. The ``flags`` bitmask can be specified to customize the save behavior.
  52. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success.