Esempio n. 1
0
        static void BunildAssetBundle()
        {
            string[] allBundles = AssetDatabase.GetAllAssetBundleNames();
            //Key为全路径,Value为包名
            Dictionary <string, string> resPathDic = new Dictionary <string, string>();

            for (int i = 0; i < allBundles.Length; i++)
            {
                string[] allBundlePath = AssetDatabase.GetAssetPathsFromAssetBundle(allBundles[i]);
                for (int j = 0; j < allBundlePath.Length; j++)
                {
                    if (allBundlePath[j].EndsWith(".cs"))
                    {
                        continue;
                    }
                    resPathDic.Add(allBundlePath[j], allBundles[i]);
                }
            }

            if (!Directory.Exists(BundleTargetPath))
            {
                Directory.CreateDirectory(BundleTargetPath);
            }
            DeleteAB();
            //生成自己的配置表
            WriteData(resPathDic);

            AssetBundleManifest manifest = BuildPipeline.BuildAssetBundles(BundleTargetPath, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);

            if (manifest == null)
            {
                Debug.LogError("AssetBundle 打包失败!");
            }
            else
            {
                Debug.Log("AssetBundle 打包完毕");
            }
            //删除manifest文件
            DeleteMainfest();
            //加密AB包
            MenumanagerEditor.EncryptAB();
        }
Esempio n. 2
0
        public static void BuildAndroid()
        {
            //打ab包
            MenumanagerEditor.NormalBuild();
            PlayerSettings.Android.keystorePass = "******";
            PlayerSettings.Android.keyaliasPass = "******";
            PlayerSettings.Android.keyaliasName = "android.keystore";
            PlayerSettings.Android.keystoreName = Application.dataPath.Replace("/Assets", "") + "/Ls_Mobile.keystore";
            BuildSetting buildSetting = GetAndoridBuildSetting();
            string       suffix       = SetAndroidSetting(buildSetting);
            //生成可执行程序
            string abPath = Application.dataPath + "/../AssetBundle/" + EditorUserBuildSettings.activeBuildTarget.ToString() + "/";

            //清空生成的文件夹
            Utility.FileHelper.DeleteDir(AndroidPath);
            Utility.FileHelper.CopyFileTo(abPath, Application.streamingAssetsPath);

            string savePath = AndroidPath + sAppName + "_Andorid" + suffix + string.Format("_{0:yyyy_MM_dd_HH_mm}.apk", DateTime.Now);

            BuildPipeline.BuildPlayer(FindEnableEditorScenes(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);
            Utility.FileHelper.DeleteDir(Application.streamingAssetsPath);
        }
Esempio n. 3
0
        //[MenuItem("Ls_Mobile/Tool/BuildPC()")]
        public static void BuildPC()
        {
            //打Ab包
            MenumanagerEditor.NormalBuild();
            BuildSetting buildSetting = GetPCBuildSetting();
            string       suffix       = SetSetting(buildSetting);
            //生成可执行程序
            string abPath = Application.dataPath + "/../AssetBundle/" + EditorUserBuildSettings.activeBuildTarget.ToString() + "/";

            //清空生成的文件夹
            Utility.FileHelper.DeleteDir(WindowsPath);
            Utility.FileHelper.CopyFileTo(abPath, Application.streamingAssetsPath);
            if (!Directory.Exists(WindowsPath))
            {
                Directory.CreateDirectory(WindowsPath);
            }
            string dir      = sAppName + "_PC" + suffix + string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now);
            string name     = string.Format("/{0}.exe", sAppName);
            string savePath = WindowsPath + dir + name;

            BuildPipeline.BuildPlayer(FindEnableEditorScenes(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None);
            Utility.FileHelper.DeleteDir(Application.streamingAssetsPath);
            WriteBuildName(dir);
        }