Ejemplo n.º 1
0
        public void ReloadConfig()
        {
            m_bundleDic.Clear();
            m_assetDic.Clear();
            string           fullPath  = PathUtils.GetVaildFullPath("bundle_info.json");
            BundleInfoConfig bundleCfg = SerializeHelper.LoadFromFile <BundleInfoConfig>(fullPath);

            if (bundleCfg != null)
            {
                for (int i = 0; i < bundleCfg.bundleInfo.Count; ++i)
                {
                    BundleInfo info = bundleCfg.bundleInfo[i];
                    m_bundleDic.Add(info.name, info);
                }
            }

            fullPath = PathUtils.GetVaildFullPath("asset_info.json");
            AssetInfoConfig assetCfg = SerializeHelper.LoadFromFile <AssetInfoConfig>(fullPath);

            if (assetCfg != null)
            {
                for (int i = 0; i < assetCfg.assetInfo.Count; ++i)
                {
                    AssetInfo info = assetCfg.assetInfo[i];
                    m_assetDic.Add(info.name, info);
                }
            }
        }
Ejemplo n.º 2
0
        public static void MakeAssetConfig()
        {
            try
            {
                AssetInfoConfig  assetInfoCfg  = new AssetInfoConfig();
                BundleInfoConfig bundleInfoCfg = new BundleInfoConfig();

                AssetBundle         manifestBundle = AssetBundle.LoadFromFile(outputPath + "/" + outputName);
                AssetBundleManifest manifest       = (AssetBundleManifest)manifestBundle.LoadAsset("AssetBundleManifest");
                string[]            allBundle      = manifest.GetAllAssetBundles();
                manifestBundle.Unload(false);

                for (int i = 0; i < allBundle.Length; ++i)
                {
                    EditorUtility.DisplayProgressBar("make asset config", "handle...", (float)i / allBundle.Length);

                    string[]   depBundle  = manifest.GetAllDependencies(allBundle[i]);
                    BundleInfo bundleInfo = new BundleInfo();
                    bundleInfoCfg.bundleInfo.Add(bundleInfo);
                    bundleInfo.name         = allBundle[i];
                    bundleInfo.dependBundle = new List <string>();
                    for (int k = 0; k < depBundle.Length; ++k)
                    {
                        bundleInfo.dependBundle.Add(depBundle[k]);
                    }

                    AssetBundle bundle = AssetBundle.LoadFromFile(outputPath + "/" + allBundle[i]);
                    if (bundle == null)
                    {
                        Debug.LogError("assetbundle can not find!");
                        continue;
                    }
                    string[] allAsset = bundle.GetAllAssetNames();
                    bundle.Unload(false);
                    for (int k = 0; k < allAsset.Length; ++k)
                    {
                        AssetInfo assetInfo = new AssetInfo();
                        assetInfoCfg.assetInfo.Add(assetInfo);
                        string assetName    = allAsset[k].Replace("assets/resources/", "");
                        string strExtension = Path.GetExtension(assetName);
                        assetInfo.name         = assetName.Replace(strExtension, "");
                        assetInfo.extName      = strExtension;
                        assetInfo.dependBundle = allBundle[i];
                    }
                }

                EditorUtility.ClearProgressBar();
                string persistentPath = Application.dataPath + "/../PersistentData/";
                SerializeHelper.SaveToFile(bundleInfoCfg, persistentPath + bundleInfoFileName, true);
                SerializeHelper.SaveToFile(assetInfoCfg, persistentPath + assetInfoFileName, true);

                MakeVersionConfig("1.2.3.1111", "http://10.0.0.252:8080/oppo_ver_cfg/");

                Debug.Log("打包结束!");
            }
            catch (System.Exception ex)
            {
                EditorUtility.ClearProgressBar();
                Debug.Log("打包失败!");
            }
        }