ResourceLoader.xml 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="ResourceLoader" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Singleton used to load resource files.
  5. </brief_description>
  6. <description>
  7. Singleton used to load resource files from the filesystem.
  8. It uses the many [ResourceFormatLoader] classes registered in the engine (either built-in or from a plugin) to load files into memory and convert them to a format that can be used by the engine.
  9. </description>
  10. <tutorials>
  11. <link title="OS Test Demo">https://godotengine.org/asset-library/asset/677</link>
  12. </tutorials>
  13. <methods>
  14. <method name="exists">
  15. <return type="bool" />
  16. <argument index="0" name="path" type="String" />
  17. <argument index="1" name="type_hint" type="String" default="&quot;&quot;" />
  18. <description>
  19. Returns whether a recognized resource exists for the given [code]path[/code].
  20. An optional [code]type_hint[/code] can be used to further specify the [Resource] type that should be handled by the [ResourceFormatLoader].
  21. </description>
  22. </method>
  23. <method name="get_dependencies">
  24. <return type="PoolStringArray" />
  25. <argument index="0" name="path" type="String" />
  26. <description>
  27. Returns the dependencies for the resource at the given [code]path[/code].
  28. </description>
  29. </method>
  30. <method name="get_recognized_extensions_for_type">
  31. <return type="PoolStringArray" />
  32. <argument index="0" name="type" type="String" />
  33. <description>
  34. Returns the list of recognized extensions for a resource type.
  35. </description>
  36. </method>
  37. <method name="has">
  38. <return type="bool" />
  39. <argument index="0" name="path" type="String" />
  40. <description>
  41. [i]Deprecated method.[/i] Use [method has_cached] or [method exists] instead.
  42. </description>
  43. </method>
  44. <method name="has_cached">
  45. <return type="bool" />
  46. <argument index="0" name="path" type="String" />
  47. <description>
  48. Returns whether a cached resource is available for the given [code]path[/code].
  49. Once a resource has been loaded by the engine, it is cached in memory for faster access, and future calls to the [method load] or [method load_interactive] methods will use the cached version. The cached resource can be overridden by using [method Resource.take_over_path] on a new resource for that same path.
  50. </description>
  51. </method>
  52. <method name="load">
  53. <return type="Resource" />
  54. <argument index="0" name="path" type="String" />
  55. <argument index="1" name="type_hint" type="String" default="&quot;&quot;" />
  56. <argument index="2" name="no_cache" type="bool" default="false" />
  57. <description>
  58. Loads a resource at the given [code]path[/code], caching the result for further access.
  59. The registered [ResourceFormatLoader]s are queried sequentially to find the first one which can handle the file's extension, and then attempt loading. If loading fails, the remaining ResourceFormatLoaders are also attempted.
  60. An optional [code]type_hint[/code] can be used to further specify the [Resource] type that should be handled by the [ResourceFormatLoader]. Anything that inherits from [Resource] can be used as a type hint, for example [Image].
  61. If [code]no_cache[/code] is [code]true[/code], the resource cache will be bypassed, and the resource will be loaded anew. Otherwise, the cached resource will be returned if it exists.
  62. Returns an empty resource if no [ResourceFormatLoader] could handle the file.
  63. GDScript has a simplified [method @GDScript.load] built-in method which can be used in most situations, leaving the use of [ResourceLoader] for more advanced scenarios.
  64. </description>
  65. </method>
  66. <method name="load_interactive">
  67. <return type="ResourceInteractiveLoader" />
  68. <argument index="0" name="path" type="String" />
  69. <argument index="1" name="type_hint" type="String" default="&quot;&quot;" />
  70. <argument index="2" name="no_cache" type="bool" default="false" />
  71. <description>
  72. Starts loading a resource interactively. The returned [ResourceInteractiveLoader] object allows to load with high granularity, calling its [method ResourceInteractiveLoader.poll] method successively to load chunks.
  73. An optional [code]type_hint[/code] can be used to further specify the [Resource] type that should be handled by the [ResourceFormatLoader]. Anything that inherits from [Resource] can be used as a type hint, for example [Image].
  74. If [code]no_cache[/code] is [code]true[/code], the resource cache will be bypassed, and the resource will be loaded anew. Otherwise, the cached resource will be returned if it exists.
  75. </description>
  76. </method>
  77. <method name="set_abort_on_missing_resources">
  78. <return type="void" />
  79. <argument index="0" name="abort" type="bool" />
  80. <description>
  81. Changes the behavior on missing sub-resources. The default behavior is to abort loading.
  82. </description>
  83. </method>
  84. </methods>
  85. <constants>
  86. </constants>
  87. </class>