Пример #1
0
        internal static void LoadABManifest()
        {
            //if (!Z.Resource.LoadFromAssetBundle)
            //    return;
            string mAssetManifestPath = mABLoadPath + mManifestName;

            AssetBundle manifestAB    = AssetBundle.LoadFromFile(mAssetManifestPath);
            TextAsset   manifestBytes = manifestAB.LoadAsset <TextAsset>(mManifestName);

            if (manifestBytes == null)
            {
                Z.Debug.Error("资源清单读取失败");
                return;
            }
            MemoryStream    stream   = new MemoryStream(manifestBytes.bytes);
            BinaryFormatter bf       = new BinaryFormatter();
            AssetManifest   manifest = (AssetManifest)bf.Deserialize(stream);

            stream.Close();

            for (int i = 0; i < manifest.AssetLst.Count; i++)
            {
                AssetElement element = manifest.AssetLst[i];
                ResourceItem resItem = Z.Pool.Take <ResourceItem>();
                resItem.Path      = element.Path;
                resItem.AssetName = element.AssetName;
                resItem.ABName    = element.ABName;
                resItem.DependAB  = element.DependAB;
                Z.Resource.ResourceItemDic.Add(resItem.Path, resItem);
                //if (Z.Resource.ResourceItemDic.ContainsKey(resItem.Path))
                //{   //路径生成了一样的crc 可能性较小 但不保证不发生
                //    Z.Log.ErrorFormat("相同的Crc!! 资源名:{0}ab包名:{1}    资源名:{2}ab包名:{3}" ,resItem.AssetName,resItem.ABName, Z.Resource.ResourceItemDic[resItem.Crc].AssetName, Z.Resource.ResourceItemDic[resItem.Crc].ABName);
                //    return;
                //}
                //else
                //{

                //}
            }
            //预留200个AB包壳
            Z.Pool.RegisterClassCustomPool(() => new AssetBundleItem(), AssetBundleItem.Clean, 200);
            return;
        }
Пример #2
0
        //private static SimpleSpinLock mSpinLock = new SimpleSpinLock();//考虑到
        internal static void LoadABManifest()
        {
            //if (!Z.Resource.LoadFromAssetBundle)
            //    return;
            string mAssetManifestPath = mABLoadPath + mManifestName;

            AssetBundle manifestAB    = AssetBundle.LoadFromFile(mAssetManifestPath);
            TextAsset   manifestBytes = manifestAB.LoadAsset <TextAsset>(mManifestName);

            if (manifestBytes == null)
            {
                Z.Debug.Error("资源清单读取失败");
                return;
            }
            MemoryStream    stream   = new MemoryStream(manifestBytes.bytes);
            BinaryFormatter bf       = new BinaryFormatter();
            AssetManifest   manifest = (AssetManifest)bf.Deserialize(stream);

            stream.Close();

            for (int i = 0; i < manifest.AssetLst.Count; i++)
            {
                AssetElement element = manifest.AssetLst[i];
                ResourceItem resItem = Z.Pool.Take <ResourceItem>();
                resItem.Path      = element.Path;
                resItem.AssetName = element.AssetName;
                resItem.ABName    = element.ABName;
                resItem.DependAB  = element.DependAB;
                resItem.ClearDependFlag();

                Z.Resource.ResourceItemDic.Add(resItem.Path, resItem);
            }
            //预留200个AB包壳
            Z.Pool.RegisterClassCustomPool(() => new AssetBundleItem(), AssetBundleItem.Clean, 200);
            Z.Pool.RegisterClassPool <ABLoadedSArgs>(60);//一次加载请求可能同时需要加载多个包 这时候每个包都要发一次事件 所以给多点 但上小于上面的数字
            return;
        }