Beispiel #1
0
        public void AddBundle(string bundlePath, AbCacheConf cacheConf, BundleStreamCreator encypt = null)
        {
            if (abLoaders.FindIndex((loader) => loader.rootPath == bundlePath) != -1)
            {
                Debug.LogError("already has bundle root:" + bundlePath);
                return;
            }
            var abLoader = new AbLoader();

            abLoader.Init(bundlePath, cacheConf.cacheSize, encypt);
            abLoader.checkCache = cacheConf.checkCacheMethod;
            abLoaders.Add(abLoader);
            StartCoroutine(abLoader.AutoClear());
        }
Beispiel #2
0
        private LoadHandle GetLoadHandle(string assetPath)
        {
            LoadHandle handle;

            //有缓存直接返回
            if (loadHandleCache.TryGetValue(assetPath, out handle))
            {
                return(handle);
            }

            #if UNITY_EDITOR
            if (isEditorMode)
            {
                handle = new EditorLoadHandle()
                {
                    assetPath = assetPath,
                };
            }
            else
            #endif
            {
                string lowerPath = assetPath.ToLower();

                //通过path,得到ab完整路径,已经对应的ab里的assetName
                //GetAbPath(path,out var abPath,out var assetName);

                string   abPath    = null;
                string   assetName = null;
                AbLoader abLoader  = abLoaders.Find((loader) => { return(loader.GetAbPath(assetPath, out abPath, out assetName)); });
                if (abLoader == null)
                {
                    //throw new Exception("path not valid:" + assetPath);
                    Debug.LogError("path not valid:" + assetPath);
                    return(handle = new InvalidLoadHandle());
                }

                handle = new AbHandle()
                {
                    abLoader  = abLoader,
                    assetName = assetName,
                    abPath    = abPath,
                };
            }


            loadHandleCache[assetPath] = handle;
            return(handle);
        }