Ejemplo n.º 1
0
        /// <summary>
        /// Given provided resource is loaded by the loader, release it.
        /// </summary>
        public static void Release(this IResourceLoader loader, Resource resource, object holder, bool unload = true)
        {
            var localPath = loader.GetLocalPath(resource);

            if (!string.IsNullOrEmpty(localPath))
            {
                loader.Release(localPath, holder, unload);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Given provided resource is loaded by the loader, hold it.
        /// </summary>
        public static void Hold(this IResourceLoader loader, Resource resource, object holder)
        {
            var localPath = loader.GetLocalPath(resource);

            if (!string.IsNullOrEmpty(localPath))
            {
                loader.Hold(localPath, holder);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Attempts to load all the available resources (optionally) filtered by a base path and holds each of them.
        /// </summary>
        public static async UniTask <IReadOnlyCollection <Resource> > LoadAndHoldAllAsync <TResource> (this IResourceLoader <TResource> loader, object holder, string path = null)
            where TResource : UnityEngine.Object
        {
            var resources = await loader.LoadAllAsync(path);

            foreach (var resource in resources)
            {
                var localPath = loader.GetLocalPath(resource);
                if (!string.IsNullOrEmpty(localPath))
                {
                    loader.Hold(localPath, holder);
                }
            }
            return(resources);
        }