コード例 #1
0
 public override bool LoadAudioClipAsync(string fileName, ResourceCacheType cache, Action <float, bool, AudioClip> onProcess)
 {
     return(LoadObjectAsync <AudioClip> (fileName, cache, onProcess));
 }
コード例 #2
0
 public abstract Material LoadMaterial(string fileName, ResourceCacheType cacheType);
コード例 #3
0
 public abstract Texture LoadTexture(string fileName, ResourceCacheType cacheType);
コード例 #4
0
 public static T Get <T>(this ICache cache, ResourceCacheType type)
     where T : class
 {
     return(cache.Get <T>(type.ToString()));
 }
コード例 #5
0
 public abstract GameObject LoadPrefab(string fileName, ResourceCacheType cacheType);
コード例 #6
0
 public override ScriptableObject LoadScriptableObject(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <ScriptableObject> (fileName, cacheType));
 }
コード例 #7
0
 public override ShaderVariantCollection LoadShaderVarCollection(string fileName,
                                                                 ResourceCacheType cacheType)
 {
     return(LoadObject <ShaderVariantCollection> (fileName, cacheType));
 }
コード例 #8
0
 public override GameObject LoadPrefab(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <GameObject> (fileName, cacheType));
 }
コード例 #9
0
 public override bool LoadPrefabAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, GameObject> onProcess, int priority = 0)
 {
     return(LoadObjectAsync <GameObject> (fileName, cacheType, priority, onProcess));
 }
コード例 #10
0
    public bool LoadObjectAsync <T>(string fileName, ResourceCacheType cacheType, int priority, Action <float, bool, T> onProcess) where T : UnityEngine.Object
    {
        if (string.IsNullOrEmpty(fileName))
        {
            return(false);
        }

        string orgFileName = fileName;

#if USE_HAS_EXT
        T obj = FindCache <T>(orgFileName);
        if (obj != null)
        {
            if (AddRefCache(orgFileName, obj, cacheType, typeof(T)) != null)
            {
                if (onProcess != null)
                {
                    onProcess(1.0f, true, obj);
                }
                return(true);
            }
        }
#endif

        if (!IsResLoaderFileName(ref fileName))
        {
            return(false);
        }

        // 同时反复调用可能产生多个Timer
        ResourceRequest request = Resources.LoadAsync(fileName, typeof(T));
        if (request == null)
        {
            return(false);
        }
        if (request.isDone)
        {
            T orgObj = request.asset as T;
            if (orgObj == null)
            {
                string err = string.Format("LoadObjectAsync: ({0}) error!", fileName);
                LogMgr.Instance.LogError(err);
                return(false);
            }

            AssetCache cache = AddRefCache(orgFileName, orgObj, cacheType, typeof(T));

#if USE_HAS_EXT
            AddCacheMap(cache);
#endif

            if (onProcess != null)
            {
                onProcess(request.progress, request.isDone, orgObj);
            }
            return(true);
        }

        request.priority = priority;

        var ret = AsyncOperationMgr.Instance.AddAsyncOperation <ResourceRequest, System.Object> (request,
                                                                                                 delegate(ResourceRequest req, bool isDone) {
            if (isDone)
            {
                T orgObj = req.asset as T;
                if (orgObj == null)
                {
                    string err = string.Format("LoadObjectAsync: ({0}) error!", fileName);
                    LogMgr.Instance.LogError(err);
                    return;
                }

                AssetCache cache = AddRefCache(orgFileName, orgObj, cacheType, typeof(T));
#if USE_HAS_EXT
                AddCacheMap(cache);
#endif

                if (onProcess != null)
                {
                    onProcess(req.progress, isDone, orgObj);
                }
            }
            else
            {
                if (onProcess != null)
                {
                    onProcess(req.progress, isDone, null);
                }
            }
        }
                                                                                                 );

        return(ret != null);
    }
コード例 #11
0
 public override Shader LoadShader(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <Shader>(fileName, cacheType));
 }
コード例 #12
0
 public static void AddOrUpdate(this ICache cache, ResourceCacheType type, object value, long ttl)
 {
     cache.AddOrUpdate(type.ToString(), value, ttl);
 }
コード例 #13
0
 public override bool LoadFontAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, Font> onProcess)
 {
     return(LoadObjectAsync <Font> (fileName, cacheType, onProcess));
 }
コード例 #14
0
 // not used addToCache
 public override bool LoadMaterialAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, Material> onProcess)
 {
     return(LoadObjectAsync <Material> (fileName, cacheType, onProcess));
 }
コード例 #15
0
 public override AnimationClip LoadAnimationClip(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <AnimationClip> (fileName, cacheType));
 }
コード例 #16
0
 public override AudioClip LoadAudioClip(string fileName, ResourceCacheType cache)
 {
     return(LoadObject <AudioClip> (fileName, cache));
 }
コード例 #17
0
 public override bool LoadAnimationClipAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, AnimationClip> onProcess, int priority = 0)
 {
     return(LoadObjectAsync <AnimationClip> (fileName, cacheType, priority, onProcess));
 }
コード例 #18
0
 // not used addToCache
 public override Material LoadMaterial(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <Material> (fileName, cacheType));
 }
コード例 #19
0
 public override bool LoadScriptableObjectAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, UnityEngine.ScriptableObject> onProcess, int priority = 0)
 {
     return(LoadObjectAsync <ScriptableObject> (fileName, cacheType, priority, onProcess));
 }
コード例 #20
0
 // not used addToCache
 public override Texture LoadTexture(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <Texture> (fileName, cacheType));
 }
コード例 #21
0
 public override bool LoadShaderVarCollectionAsync(string fileName, ResourceCacheType cacheType,
                                                   Action <float, bool, ShaderVariantCollection> onProcess, int priority = 0)
 {
     return(LoadObjectAsync <ShaderVariantCollection> (fileName, cacheType, priority, onProcess));
 }
コード例 #22
0
 // not used addToCache
 public override bool LoadTextureAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, Texture> onProcess, int priority = 0)
 {
     return(LoadObjectAsync <Texture> (fileName, cacheType, priority, onProcess));
 }
コード例 #23
0
 public static void Set(this ICache cache, ResourceCacheType type, object value, TimeSpan ts)
 {
     cache.Set(type.ToString(), value, ts);
 }
コード例 #24
0
 public override Font LoadFont(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <Font> (fileName, cacheType));
 }
コード例 #25
0
 public abstract bool LoadPrefabAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, GameObject> onProcess);
コード例 #26
0
 public override RuntimeAnimatorController LoadAniController(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <RuntimeAnimatorController> (fileName, cacheType));
 }
コード例 #27
0
 public abstract bool LoadMaterialAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, Material> onProcess);
コード例 #28
0
 public override bool LoadAniControllerAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, RuntimeAnimatorController> onProcess, int priority = 0)
 {
     return(LoadObjectAsync <RuntimeAnimatorController> (fileName, cacheType, priority, onProcess));
 }
コード例 #29
0
 public abstract bool LoadTextureAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, Texture> onProcess);
コード例 #30
0
    public bool LoadShaderAsync(string fileName, Action <float, bool, Shader> onProcess, ResourceCacheType cacheType)
    {
        bool ret = mAssetLoader.LoadShaderAsync(fileName, cacheType, onProcess);

        if (ret)
        {
            return(ret);
        }
        return(mResLoader.LoadShaderAsync(fileName, cacheType, onProcess));
    }