class_resourceformatsaver.rst 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 ResourceFormatSaver.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_ResourceFormatSaver:
  6. ResourceFormatSaver
  7. ===================
  8. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Inherited By:** :ref:`ResourceFormatSaverCrypto<class_ResourceFormatSaverCrypto>`
  10. Saves a specific resource type to a file.
  11. Description
  12. -----------
  13. The engine can save resources when you do it from the editor, or when you use the :ref:`ResourceSaver<class_ResourceSaver>` singleton. This is accomplished thanks to multiple ``ResourceFormatSaver``\ s, each handling its own format and called automatically by the engine.
  14. By default, Godot saves resources as ``.tres`` (text-based), ``.res`` (binary) or another built-in format, but you can choose to create your own format by extending this class. Be sure to respect the documented return types and values. You should give it a global class name with ``class_name`` for it to be registered. Like built-in ResourceFormatSavers, it will be called automatically when saving resources of its recognized type(s). You may also implement a :ref:`ResourceFormatLoader<class_ResourceFormatLoader>`.
  15. Methods
  16. -------
  17. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_recognized_extensions<class_ResourceFormatSaver_method_get_recognized_extensions>` **(** :ref:`Resource<class_Resource>` resource **)** virtual |
  19. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`recognize<class_ResourceFormatSaver_method_recognize>` **(** :ref:`Resource<class_Resource>` resource **)** virtual |
  21. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`int<class_int>` | :ref:`save<class_ResourceFormatSaver_method_save>` **(** :ref:`String<class_String>` path, :ref:`Resource<class_Resource>` resource, :ref:`int<class_int>` flags **)** virtual |
  23. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. Method Descriptions
  25. -------------------
  26. .. _class_ResourceFormatSaver_method_get_recognized_extensions:
  27. - :ref:`PackedStringArray<class_PackedStringArray>` **get_recognized_extensions** **(** :ref:`Resource<class_Resource>` resource **)** virtual
  28. Returns the list of extensions available for saving the resource object, provided it is recognized (see :ref:`recognize<class_ResourceFormatSaver_method_recognize>`).
  29. ----
  30. .. _class_ResourceFormatSaver_method_recognize:
  31. - :ref:`bool<class_bool>` **recognize** **(** :ref:`Resource<class_Resource>` resource **)** virtual
  32. Returns whether the given resource object can be saved by this saver.
  33. ----
  34. .. _class_ResourceFormatSaver_method_save:
  35. - :ref:`int<class_int>` **save** **(** :ref:`String<class_String>` path, :ref:`Resource<class_Resource>` resource, :ref:`int<class_int>` flags **)** virtual
  36. Saves the given resource object to a file at the target ``path``. ``flags`` is a bitmask composed with :ref:`SaverFlags<enum_ResourceSaver_SaverFlags>` constants.
  37. Returns :ref:`@GlobalScope.OK<class_@GlobalScope_constant_OK>` on success, or an :ref:`Error<enum_@GlobalScope_Error>` constant in case of failure.