Ejemplo n.º 1
0
 public override bool LoadAudioClipAsync(string fileName, ResourceCacheType cache, Action <float, bool, AudioClip> onProcess)
 {
     return(LoadObjectAsync <AudioClip> (fileName, cache, onProcess));
 }
 public abstract Material LoadMaterial(string fileName, ResourceCacheType cacheType);
 public abstract Texture LoadTexture(string fileName, ResourceCacheType cacheType);
Ejemplo n.º 4
0
 public static T Get <T>(this ICache cache, ResourceCacheType type)
     where T : class
 {
     return(cache.Get <T>(type.ToString()));
 }
 public abstract GameObject LoadPrefab(string fileName, ResourceCacheType cacheType);
Ejemplo n.º 6
0
 public override ScriptableObject LoadScriptableObject(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <ScriptableObject> (fileName, cacheType));
 }
Ejemplo n.º 7
0
 public override ShaderVariantCollection LoadShaderVarCollection(string fileName,
                                                                 ResourceCacheType cacheType)
 {
     return(LoadObject <ShaderVariantCollection> (fileName, cacheType));
 }
Ejemplo n.º 8
0
 public override GameObject LoadPrefab(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <GameObject> (fileName, cacheType));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 11
0
 public override Shader LoadShader(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <Shader>(fileName, cacheType));
 }
Ejemplo n.º 12
0
 public static void AddOrUpdate(this ICache cache, ResourceCacheType type, object value, long ttl)
 {
     cache.AddOrUpdate(type.ToString(), value, ttl);
 }
Ejemplo n.º 13
0
 public override bool LoadFontAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, Font> onProcess)
 {
     return(LoadObjectAsync <Font> (fileName, cacheType, onProcess));
 }
Ejemplo n.º 14
0
 // not used addToCache
 public override bool LoadMaterialAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, Material> onProcess)
 {
     return(LoadObjectAsync <Material> (fileName, cacheType, onProcess));
 }
Ejemplo n.º 15
0
 public override AnimationClip LoadAnimationClip(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <AnimationClip> (fileName, cacheType));
 }
Ejemplo n.º 16
0
 public override AudioClip LoadAudioClip(string fileName, ResourceCacheType cache)
 {
     return(LoadObject <AudioClip> (fileName, cache));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 18
0
 // not used addToCache
 public override Material LoadMaterial(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <Material> (fileName, cacheType));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 20
0
 // not used addToCache
 public override Texture LoadTexture(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <Texture> (fileName, cacheType));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 23
0
 public static void Set(this ICache cache, ResourceCacheType type, object value, TimeSpan ts)
 {
     cache.Set(type.ToString(), value, ts);
 }
Ejemplo n.º 24
0
 public override Font LoadFont(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <Font> (fileName, cacheType));
 }
Ejemplo n.º 25
0
 public abstract bool LoadPrefabAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, GameObject> onProcess);
Ejemplo n.º 26
0
 public override RuntimeAnimatorController LoadAniController(string fileName, ResourceCacheType cacheType)
 {
     return(LoadObject <RuntimeAnimatorController> (fileName, cacheType));
 }
Ejemplo n.º 27
0
 public abstract bool LoadMaterialAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, Material> onProcess);
Ejemplo n.º 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));
 }
Ejemplo n.º 29
0
 public abstract bool LoadTextureAsync(string fileName, ResourceCacheType cacheType, Action <float, bool, Texture> onProcess);
Ejemplo n.º 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));
    }