Esempio n. 1
0
    //构建Win64平台EXE 程序
    public static void BuildWin64Exe()
    {
        GenerateLuaWrap();
        AssetDatabase.Refresh();

#if USE_PACK_RES
        FullResBuilder.DeleteRedundantFiles(BuildTarget.StandaloneWindows);
#endif
        string version = System.Text.Encoding.UTF8.GetString(FileUtil.ReadFile(Application.dataPath + "/Resources/Version.bytes"));
        if (string.IsNullOrEmpty(version))
        {
            version = "000";
        }
        //
        version = version.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "");
        string exeFolderName = string.Empty;
        //
#if JW_DEBUG
        exeFolderName = "Debug_Arcade_" + version;
#else
        exeFolderName = "Release_Arcade_" + version;
#endif
        string outDir  = Application.dataPath + "/../../Builds/BuildWin/" + exeFolderName;
        string outPath = outDir + "/ToyRealMachine.exe";
        //
        PlayerSettings.companyName = "BCZX";
        PlayerSettings.productName = "RealMachine";

        PlayerSettings.defaultIsFullScreen       = true;
        PlayerSettings.displayResolutionDialog   = ResolutionDialogSetting.Disabled;
        PlayerSettings.resizableWindow           = false;
        PlayerSettings.forceSingleInstance       = true;
        PlayerSettings.allowFullscreenSwitch     = false;
        PlayerSettings.applicationIdentifier     = "com.bczx.arcade";
        PlayerSettings.d3d11FullscreenMode       = D3D11FullscreenMode.FullscreenWindow;
        PlayerSettings.visibleInBackground       = false;
        PlayerSettings.defaultIsNativeResolution = true;
        PlayerSettings.runInBackground           = false;
        PlayerSettings.SplashScreen.show         = false;
        PlayerSettings.forceSingleInstance       = true;

        string path = System.IO.Path.GetFullPath(outPath);
#if JW_DEBUG
        BuildOptions option = BuildOptions.AllowDebugging | BuildOptions.Development;
#else
        BuildOptions option = BuildOptions.None;
#endif
        string error = BuildPipeline.BuildPlayer(EditorBuildSettings.scenes, path, BuildTarget.StandaloneWindows64, option);
        if (error != null)
        {
            Debug.Log("BuildWinExe Error:" + error.ToString());
#if !UNITY_EDITOR
            EditorApplication.Exit(2);
#endif
        }
        //
        if (FileUtil.IsFileExist(outPath))
        {
            Debug.Log("BuildWinExe Zip:");
            //合并成Zip
            string outZipPath = Application.dataPath + "/../../Builds/BuildWin/" + exeFolderName + ".zip";
            //
            ZipHelper.CreateZip(outZipPath, outDir);
            //
            FileUtil.CopyFile(Application.dataPath + "/Resources/Version.bytes", Application.dataPath + "/../../Builds/BuildWin/Version.bytes");
        }

#if !UNITY_EDITOR
        EditorApplication.Exit(0);
#endif
    }