:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/ResourceLoader.xml. .. _class_ResourceLoader: ResourceLoader ============== **Inherits:** :ref:`Object` Singleton used to load resource files. .. rst-class:: classref-introduction-group Description ----------- Singleton used to load resource files from the filesystem. It uses the many :ref:`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. .. rst-class:: classref-introduction-group Tutorials --------- - `OS Test Demo `__ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`exists` **(** :ref:`String` path, :ref:`String` type_hint="" **)** | +-------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolStringArray` | :ref:`get_dependencies` **(** :ref:`String` path **)** | +-------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolStringArray` | :ref:`get_recognized_extensions_for_type` **(** :ref:`String` type **)** | +-------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has` **(** :ref:`String` path **)** | +-------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_cached` **(** :ref:`String` path **)** | +-------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Resource` | :ref:`load` **(** :ref:`String` path, :ref:`String` type_hint="", :ref:`bool` no_cache=false **)** | +-------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`ResourceInteractiveLoader` | :ref:`load_interactive` **(** :ref:`String` path, :ref:`String` type_hint="", :ref:`bool` no_cache=false **)** | +-------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_abort_on_missing_resources` **(** :ref:`bool` abort **)** | +-------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_ResourceLoader_method_exists: .. rst-class:: classref-method :ref:`bool` **exists** **(** :ref:`String` path, :ref:`String` type_hint="" **)** Returns whether a recognized resource exists for the given ``path``. An optional ``type_hint`` can be used to further specify the :ref:`Resource` type that should be handled by the :ref:`ResourceFormatLoader`. .. rst-class:: classref-item-separator ---- .. _class_ResourceLoader_method_get_dependencies: .. rst-class:: classref-method :ref:`PoolStringArray` **get_dependencies** **(** :ref:`String` path **)** Returns the dependencies for the resource at the given ``path``. .. rst-class:: classref-item-separator ---- .. _class_ResourceLoader_method_get_recognized_extensions_for_type: .. rst-class:: classref-method :ref:`PoolStringArray` **get_recognized_extensions_for_type** **(** :ref:`String` type **)** Returns the list of recognized extensions for a resource type. .. rst-class:: classref-item-separator ---- .. _class_ResourceLoader_method_has: .. rst-class:: classref-method :ref:`bool` **has** **(** :ref:`String` path **)** *Deprecated method.* Use :ref:`has_cached` or :ref:`exists` instead. .. rst-class:: classref-item-separator ---- .. _class_ResourceLoader_method_has_cached: .. rst-class:: classref-method :ref:`bool` **has_cached** **(** :ref:`String` path **)** Returns whether a cached resource is available for the given ``path``. Once a resource has been loaded by the engine, it is cached in memory for faster access, and future calls to the :ref:`load` or :ref:`load_interactive` methods will use the cached version. The cached resource can be overridden by using :ref:`Resource.take_over_path` on a new resource for that same path. .. rst-class:: classref-item-separator ---- .. _class_ResourceLoader_method_load: .. rst-class:: classref-method :ref:`Resource` **load** **(** :ref:`String` path, :ref:`String` type_hint="", :ref:`bool` no_cache=false **)** Loads a resource at the given ``path``, caching the result for further access. The registered :ref:`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. An optional ``type_hint`` can be used to further specify the :ref:`Resource` type that should be handled by the :ref:`ResourceFormatLoader`. Anything that inherits from :ref:`Resource` can be used as a type hint, for example :ref:`Image`. If ``no_cache`` is ``true``, the resource cache will be bypassed, and the resource will be loaded anew. Otherwise, the cached resource will be returned if it exists. Returns an empty resource if no :ref:`ResourceFormatLoader` could handle the file. GDScript has a simplified :ref:`@GDScript.load` built-in method which can be used in most situations, leaving the use of **ResourceLoader** for more advanced scenarios. .. rst-class:: classref-item-separator ---- .. _class_ResourceLoader_method_load_interactive: .. rst-class:: classref-method :ref:`ResourceInteractiveLoader` **load_interactive** **(** :ref:`String` path, :ref:`String` type_hint="", :ref:`bool` no_cache=false **)** Starts loading a resource interactively. The returned :ref:`ResourceInteractiveLoader` object allows to load with high granularity, calling its :ref:`ResourceInteractiveLoader.poll` method successively to load chunks. An optional ``type_hint`` can be used to further specify the :ref:`Resource` type that should be handled by the :ref:`ResourceFormatLoader`. Anything that inherits from :ref:`Resource` can be used as a type hint, for example :ref:`Image`. If ``no_cache`` is ``true``, the resource cache will be bypassed, and the resource will be loaded anew. Otherwise, the cached resource will be returned if it exists. .. rst-class:: classref-item-separator ---- .. _class_ResourceLoader_method_set_abort_on_missing_resources: .. rst-class:: classref-method void **set_abort_on_missing_resources** **(** :ref:`bool` abort **)** Changes the behavior on missing sub-resources. The default behavior is to abort loading. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`