/// <summary> /// Returns the loading progress of a resource that's being asynchronously loaded. /// </summary> /// <param name="resource">Resource whose load progress to check.</param> /// <param name="includeDependencies">If false the progress will reflect the load progress only for this individual /// resource. If true the progress will reflect load progress of this resource /// and all of its dependencies.</param> /// <returns>Load progress in range [0, 1].</returns> public static float GetLoadProgress(RRefBase resource, bool includeDependencies = true) { if (resource == null) { return(0.0f); } return(Internal_GetLoadProgress(resource.GetCachedPtr(), includeDependencies)); }
/// <summary> /// Releases an internal reference to the resource held by the resources system. This allows the resource /// to be unloaded when it goes out of scope, if the resource was loaded with "keepLoaded" parameter. /// /// Alternatively you can also skip manually calling <see cref="Release(RRefBase)"/> and call <see cref="UnloadUnused"/> /// which will unload all resources that do not have any external references, but you lose the fine grained control /// of what will be unloaded. /// </summary> /// <param name="resource">Resource to release</param> public static void Release(RRefBase resource) { if (resource == null) { return; } Internal_ReleaseRef(resource.GetCachedPtr()); }
/// <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); }
public bool Equals(RRefBase other) { if (ReferenceEquals(other, null)) { return(false); } Internal_GetUUID(mCachedPtr, out var lhs); Internal_GetUUID(other.mCachedPtr, out var rhs); return(lhs.Equals(rhs)); }
/// <inheritdoc/> public override bool Equals(object other) { if (ReferenceEquals(other, null)) { return(false); } if (!(other is RRefBase)) { return(false); } RRefBase otherRef = (RRefBase)other; Internal_GetUUID(mCachedPtr, out var lhs); Internal_GetUUID(otherRef.mCachedPtr, out var rhs); return(lhs.Equals(rhs)); }
/// <summary> /// Releases an internal reference to the resource held by the resources system. This allows the resource to be unloaded /// when it goes out of scope, if the resource was loaded with <see cref="keepInternalReference"/> parameter. /// /// Alternatively you can also skip manually calling release() and call unloadAllUnused() which will unload all /// resources that do not have any external references, but you lose the fine grained control of what will be unloaded. /// </summary> /// <param name="resource">Handle of the resource to release.</param> public static void Release(RRefBase resource) { Internal_release(resource); }
private static void Internal_onResourceModified(RRefBase p0) { OnResourceModified?.Invoke(p0); }
private static extern float Internal_getLoadProgress(RRefBase resource, bool includeDependencies);
private static extern void Internal_release(RRefBase resource);
/// <summary>Returns the loading progress of a resource that's being asynchronously loaded.</summary> /// <param name="resource">Resource whose load progress to check.</param> /// <param name="includeDependencies"> /// If false the progress will reflect the load progress only for this inidividual resource. If true the progress will /// reflect load progress of this resource and all of its dependencies. /// </param> /// <returns>Load progress in range [0, 1].</returns> public static float GetLoadProgress(RRefBase resource, bool includeDependencies = true) { return(Internal_getLoadProgress(resource, includeDependencies)); }
private void Internal_onResourceLoaded(RRefBase p0) { OnResourceLoaded?.Invoke(p0); }