Пример #1
0
        public override string ToString()
        {
            StringWriter sw = new StringWriter();

            foreach (KeyValuePair <string, BundleInfoMapItem> kvp in _bundleMap)
            {
                BundleInfoMapItem bmi = kvp.Value;
                sw.WriteLine(bmi.ToString());
            }
            return(sw.ToString());
        }
Пример #2
0
        internal string GetBundleNameFromOriginalName(string originalName)
        {
            BundleInfoMapItem bmi = GetBundleItemFromOriginalName(originalName);

            if (null == bmi)
            {
                return(null);
            }
            else
            {
                return(bmi.FinalName);
            }
        }
Пример #3
0
        internal BundleInfoMapItem GetBundleItemFromOriginalName(string originalName)
        {
            BundleInfoMapItem bmi = null;

            if (bundlemap.BundleMap.TryGetValue(originalName, out bmi))
            {
                return(bmi);
            }
            else
            {
                //if (!originalName.Equals(SysConf.BUNDLEMAP_FILE))
                //Logger.GetFile(LogFile.Res).LogError(originalName + " not found in BundleMap");

                return(null);
            }
        }
Пример #4
0
        public static BundleInfoMapItem GetFinalBundle(string name, bool fromWeb = false)
        {
            BundleInfoMapItem item = null;

            if (!fromWeb)
            {
                item = ResourceMgr.Instance().BundleRename.GetBundleItemFromOriginalName(name);
            }
            if (null == item)
            {
                item           = new BundleInfoMapItem();
                item.FinalName = name;
            }

            return(item);
        }
Пример #5
0
        public void BeginLoad()
        {
            mRealName = mName;
#if DEBUG_BUNDLE_CACHE
            ResourceMgr.Instance().SampleLoadEvent(mName, 2);
#endif
            BundleInfoMapItem item = GetFinalBundle(mName, IsFromWeb);
            mRealName = item.FinalName;
            string name = WWWUtil.RES_BUNDLE_ORIGINAL_NAME ? mName : mRealName;

            if (ResourceModule.Instance.UseAssetBundleLoadFromFile && mWWWType == WWWType.AssetBundle)
            {
                abRequest = WWWUtil.CreateAssetbundleAsync(name, IsFromStream, IsFromWeb);
            }
            else
            {
                loadWWW = WWWUtil.CreateWWW(name, IsRawResource, IsFromStream, IsFromWeb);
            }
            mBeginLoadTime = 0;
        }
Пример #6
0
        internal void AddWWW(string name)
        {
            foreach (string res in mListRes)
            {
                if (res == name)
                {
                    return;
                }
            }

            if (name.Length == 0)
            {
                return;
            }

            mListRes.Add(name);
            BundleInfoMapItem bundle = ResourceLoader.GetFinalBundle(name);

            if (bundle == null)
            {
                Debug.LogError("Cannot find bundle " + name);
            }
            mListAsset.Add(bundle.FinalName);
        }
Пример #7
0
        public bool AppendRead(string stream, bool Register = true, List <BundleInfoInfo> infoList = null)
        {
            StringReader sr   = new StringReader(stream);
            string       line = sr.ReadLine();

            while (null != line)
            {
                if (line.StartsWith(BUNDLE_INFO_PREFIX))
                {
                    byte[]       buf = Convert.FromBase64String(line.Substring(BUNDLE_INFO_PREFIX.Length + 1));
                    MemoryStream ms  = new MemoryStream(buf);
                    BinaryReader br  = new BinaryReader(ms);

                    int bundleCnt = br.ReadInt32();
                    for (int i = 0; i < bundleCnt; i++)
                    {
                        string           name            = br.ReadString();
                        int              size            = br.ReadInt32();
                        bool             canForceRelease = br.ReadBoolean();
                        int              assetCnt        = br.ReadInt32();
                        HashSet <string> assets          = new HashSet <string>();
                        HashSet <string> DependsOn       = new HashSet <string>();
                        string           firstAsset      = null;
                        for (int j = 0; j < assetCnt; j++)
                        {
                            string assetName = br.ReadString();

                            if (firstAsset == null)
                            {
                                firstAsset = assetName;
                            }
                            assets.Add(assetName);
                            if (Register)
                            {
                                ResourceMgr.Instance().RegisterBundleIdx(assetName, name, size);
                            }
                        }
                        if (Register)
                        {
                            BundleInfo bundle = ResourceMgr.Instance().GetBundle(name);
                            bundle.FirstAsset      = firstAsset;
                            bundle.CanForceRelease = canForceRelease;
                            int dependCnt = br.ReadInt32();
                            for (int j = 0; j < dependCnt; j++)
                            {
                                string depName = br.ReadString();
                                bundle.DependsOn.Add(depName);
                            }
                        }
                        else
                        {
                            int dependCnt = br.ReadInt32();
                            for (int j = 0; j < dependCnt; j++)
                            {
                                string depName = br.ReadString();
                                DependsOn.Add(depName);
                            }
                        }
                        if (infoList != null)
                        {
                            BundleInfoInfo _bundleInfo = new BundleInfoInfo();
                            _bundleInfo.Name         = name;
                            _bundleInfo.Size         = size;
                            _bundleInfo.Assets       = assets;
                            _bundleInfo.Dependencies = DependsOn;
                            infoList.Add(_bundleInfo);
                        }
                    }
                }
                else
                {
                    BundleInfoMapItem bmi = new BundleInfoMapItem();
                    bmi.FromString(line);
                    if (!_bundleMap.ContainsKey(bmi.Name))
                    {
                        _bundleMap.Add(bmi.Name, bmi);
                    }
                }
                line = sr.ReadLine();
            }
            return(true);
        }