Exemplo n.º 1
0
        public I_ObjectInfo LoadAsset <T>(string resPath) where T : Object
        {
            ResToAssetBundleCnf mainPackageCnf = _mainInfo.GetResToAb(resPath);

            if (mainPackageCnf == null)
            {
                return(null);
            }

            string            mainPackagePath = mainPackageCnf.PackagePath;
            AssetBundleDepCnf depsCnf         = _mainInfo.GetDepsInfo(mainPackagePath);

            if (depsCnf == null)
            {
                return(null);
            }

            foreach (var depInfo in depsCnf._childRef)
            {
                InternalSyncloadPackage(depInfo.Key);
            }

            AssetBundleInfo packageInfo = InternalSyncloadPackage(depsCnf.AbName);

            ResLog.Assert(packageInfo != null, "AssetBundleLoader LoadAsset 加载主包失败:[{0}]", resPath);

            return(packageInfo);
        }
Exemplo n.º 2
0
        public ResLoadOpertion LoadAssetAsync <T>(string resPath) where T : Object
        {
            ResToAssetBundleCnf abInfo = _mainInfo.GetResToAb(resPath);

            if (abInfo == null)
            {
                return(null);
            }

            AssetBundleDepCnf abDep = _mainInfo.GetDepsInfo(abInfo.PackagePath);

            if (abDep == null)
            {
                return(null);
            }

            foreach (var depInfo in abDep._childRef)
            {
                InternalAsyncLoadPackage(depInfo.Key);
            }

            ResLoadOpertion resLoadOperation = InternalAsyncLoadPackage(abDep.AbName);

            return(resLoadOperation);
        }
Exemplo n.º 3
0
        public bool UnloadAsset(I_ObjectInfo objectInfo)
        {
            if (objectInfo == null)
            {
                return(false);
            }
            string mainPackagePath = objectInfo.Path;

            // 3.卸载主包
            bool result = InternalUnLoad(mainPackagePath, true);

            if (!result)
            {
                return(false);
            }

            // 4.卸载依赖包
            AssetBundleDepCnf depCnf = _mainInfo.GetDepsInfo(mainPackagePath);

            if (depCnf != null)
            {
                foreach (var depInfo in depCnf._childRef)
                {
                    InternalUnLoad(depInfo.Key, false);
                }
            }
            return(true);
        }
Exemplo n.º 4
0
        private void InitReverseDep()
        {
            _reverseDepMap.Clear();
            foreach (var info in _depMap)
            {
                AssetBundleDepCnf        depInfo = info.Value;
                Dictionary <string, int> depMap  = depInfo._childRef;
                foreach (var child in depMap)
                {
                    // 儿子路径
                    string childPath = child.Key;

                    if (!_reverseDepMap.ContainsKey(childPath))
                    {
                        List <string> parents = new List <string>(8);
                        _reverseDepMap.Add(childPath, parents);
                    }
                    _reverseDepMap[childPath].Add(depInfo.AbName);
                }
            }
        }
Exemplo n.º 5
0
        public void InitInfo()
        {
            _depMap.Clear();
            _packageMap.Clear();
            _resMap.Clear();

            List <string[]> depResult = GetAbInfo(AssetBundleConst.AssetbundleDepPath);
            int             length    = depResult.Count;

            for (int i = 0; i < length; i++)
            {
                AssetBundleDepCnf dep = new AssetBundleDepCnf();
                dep.InitInfo(depResult[i]);
                _depMap.Add(dep.AbName, dep);
            }
            InitReverseDep();

            List <string[]> packageResult = GetAbInfo(AssetBundleConst.AssetbundlePackagePath);

            length = packageResult.Count;
            for (int i = 0; i < length; i++)
            {
                AssetBundlePackageCnf packageInfo = new AssetBundlePackageCnf(packageResult[i]);

                _packageMap.Add(packageInfo.PackagePath, packageInfo);
            }

            List <string[]> resResult = GetAbInfo(AssetBundleConst.AssetbundleResPath);

            length = resResult.Count;
            for (int i = 0; i < length; i++)
            {
                ResToAssetBundleCnf res = new ResToAssetBundleCnf(resResult[i]);
                _resMap.Add(res.ResPath, res);
            }
        }