ResourceFormatSaver.xml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="ResourceFormatSaver" inherits="Reference" category="Core" version="3.1.2">
  3. <brief_description>
  4. Saves a specific resource type to a file.
  5. </brief_description>
  6. <description>
  7. The engine can save resources when you do it from the editor, or when you use the [ResourceSaver] singleton. This is accomplished thanks to multiple [ResourceFormatSaver]s, each handling its own format and called automatically by the engine.
  8. By default, Godot saves resources as [code].tres[/code] (text-based), [code].res[/code] (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 [code]class_name[/code] 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 [ResourceFormatLoader].
  9. </description>
  10. <tutorials>
  11. </tutorials>
  12. <methods>
  13. <method name="get_recognized_extensions" qualifiers="virtual">
  14. <return type="PoolStringArray">
  15. </return>
  16. <argument index="0" name="resource" type="Resource">
  17. </argument>
  18. <description>
  19. Returns the list of extensions available for saving the resource object, provided it is recognized (see [method recognize]).
  20. </description>
  21. </method>
  22. <method name="recognize" qualifiers="virtual">
  23. <return type="bool">
  24. </return>
  25. <argument index="0" name="resource" type="Resource">
  26. </argument>
  27. <description>
  28. Returns whether the given resource object can be saved by this saver.
  29. </description>
  30. </method>
  31. <method name="save" qualifiers="virtual">
  32. <return type="int">
  33. </return>
  34. <argument index="0" name="path" type="String">
  35. </argument>
  36. <argument index="1" name="resource" type="Resource">
  37. </argument>
  38. <argument index="2" name="flags" type="int">
  39. </argument>
  40. <description>
  41. Saves the given resource object to a file at the target [code]path[/code]. [code]flags[/code] is a bitmask composed with [enum ResourceSaver.SaverFlags] constants.
  42. Returns [constant @GlobalScope.OK] on success, or an [enum @GlobalScope.Error] constant in case of failure.
  43. </description>
  44. </method>
  45. </methods>
  46. <constants>
  47. </constants>
  48. </class>