/// <summary> /// Loads a resource with the specified UUID asynchonously (on a separate thread). If resource is already loaded /// an existing instance is returned. Use <see cref="RRefBase.IsLoaded"/> to confirm the resource has been loaded /// before using it. Use <see cref="GetLoadProgress"/> to track the loading progress of the resource. /// </summary> /// <remarks> /// If running outside of the editor you must make sure to mark that the resource gets included in the build. If /// running inside the editor this has similar functionality as if loading using the project library. /// </remarks> /// <typeparam name="T">Type of the resource.</typeparam> /// <param name="uuid">Unique identifier of the resource to load.</param> /// <param name="flags">Flags used to control the load process.</param> /// <returns>Loaded resource, or null if resource cannot be found.</returns> public static RRef <T> LoadAsync <T>(UUID uuid, ResourceLoadFlag flags = ResourceLoadFlag.Default) where T : Resource { RRefBase rref = Internal_LoadAsyncFromUUID(ref uuid, flags).As <T>(); if (rref != null) { return(rref.As <T>()); } return(null); }
/// <summary> /// Loads a resource at the specified path asynchonously (on a separate thread). If resource is already loaded /// an existing instance is returned. Use <see cref="RRefBase.IsLoaded"/> to confirm the resource has been loaded /// before using it. Use <see cref="GetLoadProgress"/> to track the loading progress of the resource. /// </summary> /// <remarks> /// If running outside of the editor you must make sure to mark that the resource gets included in the build. If /// running inside the editor this has similar functionality as if loading using the project library. /// </remarks> /// <typeparam name="T">Type of the resource.</typeparam> /// <param name="path">Path of the resource, relative to game directory. If running from editor this will be /// relative to the project library. If a sub-resource within a file is needed, append the name /// of the subresource to the path (for example mymesh.fbx/my_animation).</param> /// <param name="flags">Flags used to control the load process.</param> /// <returns>Loaded resource, or null if resource cannot be found.</returns> public static RRef <T> LoadAsync <T>(string path, ResourceLoadFlag flags = ResourceLoadFlag.Default) where T : Resource { RRefBase rref = Internal_LoadAsync(path, flags); if (rref != null) { return(rref.As <T>()); } return(null); }