Singleton used to load resource files.
    public static class ResourceLoader

Singleton used to load resource files from the filesystem.

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.

GDScript has a simplified GD.Load(string) built-in method which can be used in most situations, leaving the use of ResourceLoader for more advanced scenarios.

Inheritance Chain

Static Properties

    public static Object Singleton { get; }

Static Methods

    public static bool Exists(string path, string typeHint = "")

Returns whether a recognized resource exists for the given path.

An optional typeHint can be used to further specify the Resource type that should be handled by the ResourceFormatLoader.

    public static string[] GetDependencies(string path)

Returns the dependencies for the resource at the given path.

    public static string[] GetRecognizedExtensionsForType(string type)

Returns the list of recognized extensions for a resource type.

    public static bool Has(string path)

Deprecated method. Use HasCached(string) or Exists(string, string) instead.

    public static bool HasCached(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 Load(string, string, bool) or LoadInteractive(string, string) methods will use the cached version. The cached resource can be overridden by using Resource.TakeOverPath(string) on a new resource for that same path.

    public static T Load<T>(string path) where T

    public static Resource Load(string path, string typeHint = "", bool noCache = false)

Loads a resource at the given path, caching the result for further access.

The registered ResourceFormatLoaders 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 typeHint can be used to further specify the Resource type that should be handled by the ResourceFormatLoader.

If noCache 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 ResourceFormatLoader could handle the file.

    public static ResourceInteractiveLoader LoadInteractive(string path, string typeHint = "")

Starts loading a resource interactively. The returned ResourceInteractiveLoader object allows to load with high granularity, calling its ResourceInteractiveLoader.Poll() method successively to load chunks.

An optional typeHint can be used to further specify the Resource type that should be handled by the ResourceFormatLoader.

    public static void SetAbortOnMissingResources(bool abort)

Changes the behavior on missing sub-resources. The default behavior is to abort loading.

Tags: