Пример #1
0
        /// <summary>
        /// 根据jenkins的参数读取到BuildSetting里
        /// </summary>
        /// <returns></returns>
        static BuildSetting GetPCBuildSetting()
        {
            string[]     parameters   = Environment.GetCommandLineArgs();
            BuildSetting buildSetting = new BuildSetting();

            foreach (var str in parameters)
            {
                if (str.StartsWith("Version"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        buildSetting.Version = tempParam[1].Trim();
                    }
                }
                else if (str.StartsWith("Build"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        buildSetting.Build = tempParam[1].Trim();
                    }
                }
                else if (str.StartsWith("Name"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        buildSetting.Name = tempParam[1].Trim();
                    }
                }
                else if (str.StartsWith("Debug"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        bool.TryParse(tempParam[1], out buildSetting.Debug);
                    }
                }
            }

            return(buildSetting);
        }
Пример #2
0
        static string SetIOSSetting(BuildSetting setting)
        {
            string suffix = "_";

            if (!string.IsNullOrEmpty(setting.Version))
            {
                PlayerSettings.bundleVersion = setting.Version;
                suffix += setting.Version;
            }
            if (!string.IsNullOrEmpty(setting.Build))
            {
                PlayerSettings.iOS.buildNumber = setting.Build;
                suffix += "_" + setting.Build;
            }
            if (!string.IsNullOrEmpty(setting.Name))
            {
                PlayerSettings.productName = setting.Name;
                //PlayerSettings.applicationIdentifier = "com.TTT." + setting.Name;
            }

            if (setting.MulRendering)
            {
                PlayerSettings.MTRendering = true;
                suffix += "_MTR";
            }
            else
            {
                PlayerSettings.MTRendering = false;
            }

            if (setting.DynamicBatching)
            {
                suffix += "_Dynamic";
            }
            else
            {
            }

            return(suffix);
        }
Пример #3
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);
        }
Пример #4
0
        public static void BuildIOS()
        {
            //打ab包
            BundleEditor.Build();
            BuildSetting buildSetting = GetIOSBuildSetting();
            string       suffix       = SetIOSSetting(buildSetting);

            //生成可执行程序
            string abPath = Application.dataPath + "/../AssetBundle/" + EditorUserBuildSettings.activeBuildTarget.ToString() + "/";

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


            string name     = sAppName + "_IOS" + suffix + string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now);
            string savePath = iOSPath + name;

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

            WriteBuildName(name);
        }
Пример #5
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);
        }
Пример #6
0
        static BuildSetting GetAndoridBuildSetting()
        {
            string[]     parameters   = Environment.GetCommandLineArgs();
            BuildSetting buildSetting = new BuildSetting();

            foreach (string str in parameters)
            {
                if (str.StartsWith("Place"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        buildSetting.Place = (Place)Enum.Parse(typeof(Place), tempParam[1], true);
                    }
                }
                else if (str.StartsWith("Version"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        buildSetting.Version = tempParam[1].Trim();
                    }
                }
                else if (str.StartsWith("Build"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        buildSetting.Build = tempParam[1].Trim();
                    }
                }
                else if (str.StartsWith("Name"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        buildSetting.Name = tempParam[1].Trim();
                    }
                }
                else if (str.StartsWith("Debug"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        bool.TryParse(tempParam[1], out buildSetting.Debug);
                    }
                }
                else if (str.StartsWith("MulRendering"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        bool.TryParse(tempParam[1], out buildSetting.MulRendering);
                    }
                }
                else if (str.StartsWith("IL2CPP"))
                {
                    var tempParam = str.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    if (tempParam.Length == 2)
                    {
                        bool.TryParse(tempParam[1], out buildSetting.IL2CPP);
                    }
                }
            }
            return(buildSetting);
        }