class_resourcesaver.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/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. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Singleton for saving Godot-specific resource types to the filesystem.
  15. 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``).
  16. .. rst-class:: classref-reftable-group
  17. Methods
  18. -------
  19. .. table::
  20. :widths: auto
  21. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_recognized_extensions<class_ResourceSaver_method_get_recognized_extensions>` **(** :ref:`Resource<class_Resource>` type **)** |
  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. .. rst-class:: classref-section-separator
  27. ----
  28. .. rst-class:: classref-descriptions-group
  29. Enumerations
  30. ------------
  31. .. _enum_ResourceSaver_SaverFlags:
  32. .. rst-class:: classref-enumeration
  33. enum **SaverFlags**:
  34. .. _class_ResourceSaver_constant_FLAG_RELATIVE_PATHS:
  35. .. rst-class:: classref-enumeration-constant
  36. :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` **FLAG_RELATIVE_PATHS** = ``1``
  37. Save the resource with a path relative to the scene which uses it.
  38. .. _class_ResourceSaver_constant_FLAG_BUNDLE_RESOURCES:
  39. .. rst-class:: classref-enumeration-constant
  40. :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` **FLAG_BUNDLE_RESOURCES** = ``2``
  41. Bundles external resources.
  42. .. _class_ResourceSaver_constant_FLAG_CHANGE_PATH:
  43. .. rst-class:: classref-enumeration-constant
  44. :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` **FLAG_CHANGE_PATH** = ``4``
  45. Changes the :ref:`Resource.resource_path<class_Resource_property_resource_path>` of the saved resource to match its new location.
  46. .. _class_ResourceSaver_constant_FLAG_OMIT_EDITOR_PROPERTIES:
  47. .. rst-class:: classref-enumeration-constant
  48. :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` **FLAG_OMIT_EDITOR_PROPERTIES** = ``8``
  49. Do not save editor-specific metadata (identified by their ``__editor`` prefix).
  50. .. _class_ResourceSaver_constant_FLAG_SAVE_BIG_ENDIAN:
  51. .. rst-class:: classref-enumeration-constant
  52. :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` **FLAG_SAVE_BIG_ENDIAN** = ``16``
  53. Save as big endian (see :ref:`File.endian_swap<class_File_property_endian_swap>`).
  54. .. _class_ResourceSaver_constant_FLAG_COMPRESS:
  55. .. rst-class:: classref-enumeration-constant
  56. :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` **FLAG_COMPRESS** = ``32``
  57. Compress the resource on save using :ref:`File.COMPRESSION_ZSTD<class_File_constant_COMPRESSION_ZSTD>`. Only available for binary resource types.
  58. .. _class_ResourceSaver_constant_FLAG_REPLACE_SUBRESOURCE_PATHS:
  59. .. rst-class:: classref-enumeration-constant
  60. :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` **FLAG_REPLACE_SUBRESOURCE_PATHS** = ``64``
  61. Take over the paths of the saved subresources (see :ref:`Resource.take_over_path<class_Resource_method_take_over_path>`).
  62. .. rst-class:: classref-section-separator
  63. ----
  64. .. rst-class:: classref-descriptions-group
  65. Method Descriptions
  66. -------------------
  67. .. _class_ResourceSaver_method_get_recognized_extensions:
  68. .. rst-class:: classref-method
  69. :ref:`PoolStringArray<class_PoolStringArray>` **get_recognized_extensions** **(** :ref:`Resource<class_Resource>` type **)**
  70. Returns the list of extensions available for saving a resource of a given type.
  71. .. rst-class:: classref-item-separator
  72. ----
  73. .. _class_ResourceSaver_method_save:
  74. .. rst-class:: classref-method
  75. :ref:`Error<enum_@GlobalScope_Error>` **save** **(** :ref:`String<class_String>` path, :ref:`Resource<class_Resource>` resource, :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` flags=0 **)**
  76. Saves a resource to disk to the given path, using a :ref:`ResourceFormatSaver<class_ResourceFormatSaver>` that recognizes the resource object.
  77. The ``flags`` bitmask can be specified to customize the save behavior.
  78. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success.
  79. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  80. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  81. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  82. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`