ResourceLoader.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="ResourceLoader" inherits="Object" version="3.3">
  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. </return>
  17. <argument index="0" name="path" type="String">
  18. </argument>
  19. <argument index="1" name="type_hint" type="String" default="&quot;&quot;">
  20. </argument>
  21. <description>
  22. Returns whether a recognized resource exists for the given [code]path[/code].
  23. An optional [code]type_hint[/code] can be used to further specify the [Resource] type that should be handled by the [ResourceFormatLoader].
  24. </description>
  25. </method>
  26. <method name="get_dependencies">
  27. <return type="PoolStringArray">
  28. </return>
  29. <argument index="0" name="path" type="String">
  30. </argument>
  31. <description>
  32. Returns the dependencies for the resource at the given [code]path[/code].
  33. </description>
  34. </method>
  35. <method name="get_recognized_extensions_for_type">
  36. <return type="PoolStringArray">
  37. </return>
  38. <argument index="0" name="type" type="String">
  39. </argument>
  40. <description>
  41. Returns the list of recognized extensions for a resource type.
  42. </description>
  43. </method>
  44. <method name="has">
  45. <return type="bool">
  46. </return>
  47. <argument index="0" name="path" type="String">
  48. </argument>
  49. <description>
  50. [i]Deprecated method.[/i] Use [method has_cached] or [method exists] instead.
  51. </description>
  52. </method>
  53. <method name="has_cached">
  54. <return type="bool">
  55. </return>
  56. <argument index="0" name="path" type="String">
  57. </argument>
  58. <description>
  59. Returns whether a cached resource is available for the given [code]path[/code].
  60. 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.
  61. </description>
  62. </method>
  63. <method name="load">
  64. <return type="Resource">
  65. </return>
  66. <argument index="0" name="path" type="String">
  67. </argument>
  68. <argument index="1" name="type_hint" type="String" default="&quot;&quot;">
  69. </argument>
  70. <argument index="2" name="no_cache" type="bool" default="false">
  71. </argument>
  72. <description>
  73. Loads a resource at the given [code]path[/code], caching the result for further access.
  74. 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.
  75. 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].
  76. 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.
  77. Returns an empty resource if no [ResourceFormatLoader] could handle the file.
  78. 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.
  79. </description>
  80. </method>
  81. <method name="load_interactive">
  82. <return type="ResourceInteractiveLoader">
  83. </return>
  84. <argument index="0" name="path" type="String">
  85. </argument>
  86. <argument index="1" name="type_hint" type="String" default="&quot;&quot;">
  87. </argument>
  88. <description>
  89. 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.
  90. 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].
  91. </description>
  92. </method>
  93. <method name="set_abort_on_missing_resources">
  94. <return type="void">
  95. </return>
  96. <argument index="0" name="abort" type="bool">
  97. </argument>
  98. <description>
  99. Changes the behavior on missing sub-resources. The default behavior is to abort loading.
  100. </description>
  101. </method>
  102. </methods>
  103. <constants>
  104. </constants>
  105. </class>