コード例 #1
0
 /// <summary>
 /// 打AB后的回调
 /// </summary>
 public static void OnAfterBuildAB(BuildParams buildParam)
 {
     if (onAfterBuildAB != null)
     {
         onAfterBuildAB(buildParam);
     }
 }
コード例 #2
0
        private static void BuildXCodeProject(BuildParams param)
        {
#if UNITY_EDITOR_OSX
            if (param.target != BuildTarget.iOS)
            {
                return;
            }
            var xcodeprojPath = Application.dataPath + "/../xgame/Unity-iPhone.xcodeproj";
            var projPath      = xcodeprojPath + "/project.pbxproj";
            if (!File.Exists(projPath))
            {
                BuildLog.LogError("xcode project path ERROR:" + projPath);
                return;
            }
            PBXProject proj = new PBXProject();
            proj.ReadFromFile(projPath);
            BuildLog.Log("open xcode project:" + proj);
            var target = proj.GetUnityMainTargetGuid();

            File.WriteAllText(projPath, proj.WriteToString());
            var askForBuildLocation = false;
            EditorUserBuildSettings.selectedBuildTargetGroup = BuildTargetGroup.iOS;
            BuildHelper.RefectionInvoke(BuildHelper.EditorAssembly, "UnityEditor.BuildPlayerWindow",
                                        "BuildPlayerAndRun", null, new Type[] { typeof(bool) }, new object[] { askForBuildLocation });
#endif
        }
コード例 #3
0
 /// <summary>
 /// 打AB前的回调
 /// </summary>
 public static void OnBeforeBuildAB(BuildParams buildParam)
 {
     if (onBeforeBuildAB != null)
     {
         onBeforeBuildAB(buildParam);
     }
 }
コード例 #4
0
ファイル: BuildTool.cs プロジェクト: gbyh/XGame
 public static void BuildOSXAB()
 {
     if (s_Param == null)
     {
         s_Param = GetBuildParamsByCommandArgs(BuildTarget.StandaloneWindows);
     }
     BuildAB(BuildTarget.StandaloneOSX, s_Param);
 }
コード例 #5
0
ファイル: BuildTool.cs プロジェクト: gbyh/XGame
 public static void BuildWindow()
 {
     if (s_Param == null)
     {
         s_Param = GetBuildParamsByCommandArgs(BuildTarget.StandaloneWindows);
     }
     Debug.LogError(s_Param);
 }
コード例 #6
0
 /// <summary>
 /// 打包体后的回调
 /// </summary>
 public static void OnAfterBuildPackage(BuildParams buildParam, bool success)
 {
     SceneTool.RefreshSettingList(false);
     if (onAfterBuildPackage != null)
     {
         onAfterBuildPackage(buildParam);
     }
 }
コード例 #7
0
 /// <summary>
 /// 打包体前的回调
 /// </summary>
 public static void OnBeforeBuildPackage(BuildParams buildParam)
 {
     if (onBeforeBuildPackage != null)
     {
         onBeforeBuildPackage(buildParam);
     }
     SceneTool.RefreshSettingList(true);
     EditorSceneManager.OpenScene(buildParam.startScene);
 }
コード例 #8
0
ファイル: BuildParams.cs プロジェクト: gbyh/XGame
        public static BuildParams Parse(string strParams)
        {
            var param = new BuildParams();

            if (string.IsNullOrEmpty(strParams))
            {
                return(param);
            }
            if (!regex.IsMatch(strParams))
            {
                return(param);
            }
            strParams = strParams.Replace('{', ' ');
            strParams = strParams.Replace('}', ' ');
            var alls = strParams.Split(',');

            foreach (var str in alls)
            {
                var subs = str.Split(new char[] { '=', ':' });
                if (subs == null || subs.Length != 2)
                {
                    continue;
                }
                var key   = subs[0].Trim();
                var value = subs[1].Trim();
                if (key.Equals("productName"))
                {
                    param.productName = value;
                }
                else if (key.Equals("apkVersion"))
                {
                    param.apkVersion = value;
                }
                else if (key.Equals("resVersion"))
                {
                    param.resVersion = value;
                }
                else if (key.Equals("applicationIdentifier"))
                {
                    param.resVersion = value;
                }
                else if (key.Equals("bundleVersionCode"))
                {
                    param.bundleVersionCode = ParseInt(value);
                }
                else if (key.Equals("isDebug"))
                {
                    param.isDebug = ParseBool(value);
                }
                else if (key.Equals("appleDeveloperTeamID"))
                {
                    param.appleDeveloperTeamID = value;
                }
            }
            return(param);
        }
コード例 #9
0
ファイル: BuildTool.cs プロジェクト: gbyh/XGame
        private static void BuildAB(BuildTarget target, BuildParams param)
        {
            var abDir  = "Res_AB/" + target;
            var abPath = Application.dataPath + "/../" + abDir;
            var option = BuildAssetBundleOptions.None;

            option |= BuildAssetBundleOptions.ChunkBasedCompression;
            BuildHelper.CreateDir(abPath);
            BuildPipeline.BuildAssetBundles(abDir, option, target);
        }
コード例 #10
0
        private static void BuildAB(BuildParams param, bool onlyBuildAB)
        {
            var abDir  = BuildHelper.GetABDir(param.target);
            var abPath = BuildHelper.GetABDirPath(param.target);
            var option = BuildAssetBundleOptions.None;

            option |= BuildAssetBundleOptions.ChunkBasedCompression;
            BuildHelper.CreateDir(abPath);
            BuildPipeline.BuildAssetBundles(abDir, option, param.target);
            BuildLog.Log("BuildAB DONE!");
        }
コード例 #11
0
        private static void BuildPackage(BuildParams param)
        {
            BuildRegister.OnBeforeBuildPackage(param);
            var flag = BuildPlayer(param);

            BuildRegister.OnAfterBuildPackage(param, flag);
            if (flag)
            {
                BuildXCodeProject(param);
            }
        }
コード例 #12
0
 private static void InitBuildParams(BuildTarget target)
 {
     if (s_Param == null)
     {
         s_Param = BuildHelper.GetBuildParamsFromCommandLine(target);
         BuildLog.Log("BuildParams:" + s_Param);
     }
     else
     {
         s_Param.target = target;
     }
 }
コード例 #13
0
ファイル: BuildTool.cs プロジェクト: gbyh/XGame
        private static BuildParams GetBuildParamsByCommandArgs(BuildTarget target)
        {
            BuildParams param;
            var         args = Environment.GetCommandLineArgs();

            if (Application.isBatchMode && args != null && args.Length >= 10)
            {
                var strParams = args[9];
                param = BuildParams.Parse(strParams);
            }
            else
            {
                param = new BuildParams();
            }
            return(param);
        }
コード例 #14
0
        private static bool BuildPlayer(BuildParams param)
        {
            var sourAbPath = BuildHelper.GetABDirPath(param.target);
            var destAbPath = Application.streamingAssetsPath;

            if (!Directory.Exists(sourAbPath))
            {
                BuildLog.LogError("ab path not exists:" + sourAbPath);
                return(false);
            }
            BuildHelper.ClearDir(destAbPath);
            BuildHelper.CopyDir(sourAbPath, destAbPath, ".manifest|.meta");

            PlayerSettings.productName                     = param.productName;
            PlayerSettings.companyName                     = param.companyName;
            PlayerSettings.applicationIdentifier           = param.applicationIdentifier;
            PlayerSettings.bundleVersion                   = param.version;
            PlayerSettings.Android.bundleVersionCode       = param.GetVersionCode();
            PlayerSettings.iOS.buildNumber                 = param.GetVersionCode().ToString();
            PlayerSettings.iOS.appleEnableAutomaticSigning = true;
            PlayerSettings.iOS.appleDeveloperTeamID        = param.appleDeveloperTeamID;
            BuildPlayerOptions op = new BuildPlayerOptions();

            op.scenes           = new[] { param.startScene };
            op.locationPathName = param.GetLocationPathName();
            op.target           = param.target;
            op.options          = param.isDebug ?
                                  (BuildOptions.Development | BuildOptions.AllowDebugging | BuildOptions.ConnectWithProfiler) :
                                  BuildOptions.None;

            var result  = BuildPipeline.BuildPlayer(op);
            var summary = result.summary;

            if (summary.result == BuildResult.Succeeded)
            {
            }
            if (summary.result == BuildResult.Failed)
            {
                return(false);
            }
            return(true);
        }
コード例 #15
0
ファイル: BuildTool.cs プロジェクト: gbyh/XGame
        private static void BuildPlayer(BuildTarget target, BuildParams param)
        {
            PlayerSettings.productName                     = param.productName;
            PlayerSettings.applicationIdentifier           = param.applicationIdentifier;
            PlayerSettings.bundleVersion                   = param.apkVersion;
            PlayerSettings.Android.bundleVersionCode       = param.bundleVersionCode;
            PlayerSettings.iOS.buildNumber                 = param.bundleVersionCode.ToString();
            PlayerSettings.iOS.appleEnableAutomaticSigning = true;
            PlayerSettings.iOS.appleDeveloperTeamID        = param.appleDeveloperTeamID;

            BuildPlayerOptions op = new BuildPlayerOptions();

            op.scenes  = new[] { param.startScene };
            op.target  = target;
            op.options = param.isDebug ? (BuildOptions.Development | BuildOptions.AllowDebugging | BuildOptions.ConnectWithProfiler) :
                         BuildOptions.None;

            var result  = BuildPipeline.BuildPlayer(op);
            var summary = result.summary;
        }