// Called when we press "build" button in the Build Utility window
    public static void m_Build()
    {
        //string buildName = "Game_002" + "_" + AppInfo.buildDateAndCount;
        string buildName       = AppInfo.productName + "_" + AppInfo.buildDateAndCount;
        string destinationPath = GenerateBuildPath(buildName);

        CreateDirectoryForBuild(destinationPath);

        // Type required scenes here!
        //string[] scenes = { "Assets/Scene/MyScene_002.unity" };
        //BuildPipeline.BuildPlayer(scenes, destinationPath + "/" + buildName + ".exe", BuildTarget.StandaloneWindows64, BuildOptions.ShowBuiltPlayer);
        BuildPipeline.BuildPlayer(AppInfo.scenes, destinationPath + "/" + buildName + ".exe", BuildTarget.StandaloneWindows64, BuildOptions.ShowBuiltPlayer);

        // Overwrite the file to update buildCount!
        AppInfo.OverwriteBuildDateAndCountToFile(GetAppInfoDataPath(AppInfo.productName));

        // Find target directory to copy files into it
        DirectoryInfo targetDir = new DirectoryInfo(destinationPath + "/" + buildName + "_Data" + "/StreamingAssets");

        // Copy general files
        string        sourcePath_general = GetIncludePath("General");
        DirectoryInfo sourceDir_general  = new DirectoryInfo(sourcePath_general);

        BuildFileExt.CopyAllTo(sourceDir_general, targetDir);

        // Copy specific files
        string        sourcePath = GetIncludePath(AppInfo.productName);
        DirectoryInfo sourceDir  = new DirectoryInfo(sourcePath);

        BuildFileExt.CopyAllTo(sourceDir, targetDir);
    }
    static void CreateDirectoryForBuild(string _destinationPath)
    {
        DirectoryInfo buildDir = new DirectoryInfo(_destinationPath);

        // If the directory already exists, delete it first
        if (buildDir.Exists)
        {
            Debug.LogWarning("buildDir already exists. Delete it first!");
            BuildFileExt.MakeFilesWritable(buildDir);

            Directory.Delete(_destinationPath, true);
        }

        // and then create the directory
        buildDir.Create();
        Debug.Log("Created directory for build: " + _destinationPath);
    }
Esempio n. 3
0
    void OnGUI()
    {
        EditorGUILayout.Space();
        GUILayout.Label("Please Enter Changelog Before Build!");
        GUILayout.Label(AppInfo.productName, EditorStyles.boldLabel);
        GUILayout.Label(AppInfo.buildDateAndCount, EditorStyles.boldLabel);
        EditorGUILayout.Space();

        changeLogString = EditorGUILayout.TextArea(changeLogString, GUILayout.MinHeight(200));

        if (GUILayout.Button("Build"))
        {
            // If nothing is typed then do nothing
            if (changeLogString == "")
            {
                return;
            }

            BuildFileExt.EditChangelog(changelogPath, changeLogString);
            BuildUtility.m_Build();
            this.Close();
        }
    }