Beispiel #1
0
        public static void PackPkgAssets()
        {
            try
            {
                string deppath = Application.streamingAssetsPath + "/" + BundleConfig.ABSavePath + "/" + BundleConfig.ABVersionPath;

                if (File.Exists(deppath))
                {
                    byte[]         bys      = File.ReadAllBytes(deppath);
                    BundlePkgAsset pkgasset = ScriptableObject.CreateInstance <BundlePkgAsset>();
                    pkgasset.bytes = bys;

                    //暂时不先删除原始资源dep.all
                    string resname = "Assets/dep.asset";
                    AssetDatabase.CreateAsset(pkgasset, resname);

                    AssetBundleBuild build = new AssetBundleBuild();
                    build.assetBundleName = BundleConfig.depAssetBundlePath;
                    build.assetNames      = new string[] { resname };

                    BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath + "/" + BundleConfig.ABSavePath, new AssetBundleBuild[] { build }, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);
                    AssetDatabase.DeleteAsset(resname);
                }
            }
            catch (System.Exception ex)
            {
                LogMgr.LogError(ex);
                EditorUtility.ClearProgressBar();
            }
        }
Beispiel #2
0
 private byte[] CreateAssetbundleBytes(out AssetBundle ab)
 {
     ab = AssetBundle.LoadFromFile(BundlePathConvert.GetRunningPath(BundleConfig.depAssetBundlePath));
     if (ab != null)
     {
         BundlePkgAsset asset = ab.LoadAsset <BundlePkgAsset>(ab.GetAllAssetNames()[0]);
         return(asset.bytes);
     }
     return(null);
 }