Example #1
0
    /// <summary>
    /// save hotfixUrl and hotfix macro
    /// </summary>
    /// <param name="para"></param>
    /// <returns></returns>
    private static bool HandleHotFix(GameBuilderParameter para)
    {
        if (para.EnableHotFix)
        {
            var url = para.HotFixUrl;

            if (String.IsNullOrEmpty(url))
            {
                Debug.LogError("BuildGame HotFixUrl is empty");
                return(false);
            }

            FileUtils.WriteFile(GameConst.GameResourceRootDir + "/" + VersionConst.CustomSeverUrlFileName, url);

            url = FileUtils.RemoveLastSeparator(url);
            FileUtils.DelFile(GameConst.GameResourceRootDir + "/" + VersionConst.CustomSeverUrlFileName);
            FileUtils.WriteFile(GameConst.GameResourceRootDir + "/" + VersionConst.CustomSeverUrlFileName, url);

            para.MacroDefines = BuilderEditorUtils.RemoveMacro(para.MacroDefines, BuilderEditorUtils.NoHotFixMacro);
            para.MacroDefines =
                BuilderEditorUtils.AddMacro(para.MacroDefines, BuilderEditorUtils.CustomServerHotFixMacro);
        }
        else
        {
            para.MacroDefines =
                BuilderEditorUtils.RemoveMacro(para.MacroDefines, BuilderEditorUtils.CustomServerHotFixMacro);
            para.MacroDefines = BuilderEditorUtils.AddMacro(para.MacroDefines, BuilderEditorUtils.NoHotFixMacro);
        }
        return(true);
    }
Example #2
0
    /// <summary>
    /// 构建设置
    /// </summary>
    /// <param name="para"></param>
    private static void SetupSetting(GameBuilderParameter para)
    {
        Debug.Log("SetupSetting");
        BuildTarget      buildTarget      = para.BuildTarget;
        BuildTargetGroup buildTargetGroup = PlatformEditorUtils.GetSelectedBuildTargetGroup(buildTarget);

        //EditorUserBuildSettings.SwitchActiveBuildTarget(buildTargetGroup, buildTarget);
        EditorUserBuildSettings.SwitchActiveBuildTarget(buildTarget);

        // 仅当有出包时才处理
        if (para.BuildMode != BuildMode.Patch)
        {
            // 版本号
            PlayerSettings.bundleVersion = para.BuildVersion.GetVersionString();
            //PlayerSettings.applicationIdentifier = para.BundleIdentifier;

            if (buildTarget == BuildTarget.Android)
            {
                PlayerSettings.Android.bundleVersionCode = para.BuildVersion.GetVersionCode();

                if (para.ExportProject)
                {
                    EditorUserBuildSettings.androidBuildSystem =
                        para.UseGradle ? AndroidBuildSystem.Gradle : AndroidBuildSystem.ADT;
                }
                else
                {
                    EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Internal;
                }
            }
            else if (buildTarget == BuildTarget.iOS)
            {
                PlayerSettings.iOS.buildNumber = para.BuildVersion.GetVersionCode().ToString();
            }

            //-如果是多线程渲染版本开启多线程渲染-//
            //PlayerSettings.SetMobileMTRendering(buildTargetGroup, para.Multithreaded);
            PlayerSettings.MTRendering = para.Multithreaded;

            //-打包之前先设置一下 预定义标签, 这时设置的宏,后面的代码不能马上生效,但BuildPlayer可以生效
            string macroDefines = para.MacroDefines;
            if (!String.IsNullOrEmpty(macroDefines))
            {
                macroDefines = para.UseMono2X ?
                               BuilderEditorUtils.AddMacro(macroDefines, "USE_MONO") :
                               BuilderEditorUtils.RemoveMacro(macroDefines, "USE_MONO");

                PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, macroDefines);
            }

            DoMonoSetting(para.UseMono2X, buildTargetGroup);
        }
    }