コード例 #1
0
        // Start Build Pipeline process
        public static IEnumerator ProcessBuildPipeline(BuildConfiguration config, ProjectSettings projectSettings)
        {
            if (config)                                                                                        // If the build configuration is not null
            {
                for (int t = 0; t < config.buildTargets.Count; t++)                                            // Iterate build targets
                {
                    BuildTarget target    = config.buildTargets[t];                                            // Get current target
                    string      directory = UnityEngine.Application.dataPath.Replace("/Assets", "/Builds");    // Get directory
                    if (target.nameOverride != null && target.nameOverride.Length > 0)                         // If use name override from the target
                    {
                        directory = target.nameOverride;                                                       // Use
                    }
                    else if (config.nameOverride != null && config.nameOverride.Length > 0)                    // Else if use name override from the whole config
                    {
                        directory = config.nameOverride;                                                       // Use
                    }
                    string applicationName = GetApplicationName(target, projectSettings, config.nameOverride); // Get application name

                    BuildSettings.SetApplicationSettings(target, AppendProductName(target));

                    if (SetGraphicsAPI(target) == false)                                                           // Check if Graphics API can be set to the specified target
                    {
                        Debug.LogError("Failed to build Player, Directory: " + directory + "/" + applicationName); // Log error
                        continue;                                                                                  // Go to next target
                    }

                    string build = BuildClient(target, directory, applicationName);                 // Build client

                    while (UnityEditor.BuildPipeline.isBuildingPlayer == true)                      // Wait for build to finish
                    {
                        yield return(null);                                                         // Wait
                    }
                    if (build == "")                                                                // If build succeeded
                    {
                        Debug.Log("Built Player, Directory: " + directory + "/" + applicationName); // Log success
                    }
                    else // If build failed
                    {
                        Debug.LogError("Failed to build Player, Directory: " + directory + "/" + applicationName); // Log failure
                        Debug.LogError(build);                                                                     // Return build fail log
                    }
                }
            }
            else // Null build configuartion
            {
                Debug.LogError("No Build Configuration file assigned. Please assign a Build Configuration file in the Build Pipeline window"); // Log error
            }
        }
コード例 #2
0
ファイル: BuildPipeline.cs プロジェクト: luco2018/UTF_Core
        // Start Build Pipeline process
        public static IEnumerator ProcessBuildPipeline(BuildConfiguration config, ProjectSettings projectSettings)
        {
            if (config) // If the build configuration is not null
            {
                string outputPath = "";
                for (int t = 0; t < config.buildTargets.Count; t++)                                            // Iterate build targets
                {
                    BuildTarget target    = config.buildTargets[t];                                            // Get current target
                    string      directory = UnityEngine.Application.dataPath.Replace("/Assets", "/Builds");    // Get directory
                    if (target.nameOverride != null && target.nameOverride.Length > 0)                         // If use name override from the target
                    {
                        directory = target.nameOverride;                                                       // Use
                    }
                    else if (config.nameOverride != null && config.nameOverride.Length > 0)                    // Else if use name override from the whole config
                    {
                        directory = config.nameOverride;                                                       // Use
                    }
                    string applicationName = GetApplicationName(target, projectSettings, config.nameOverride); // Get application name

                    BuildSettings.SetApplicationSettings(target);

                    //Set Script logging settings
                    if (config.enableScriptLogging)
                    {
                        SetScriptLoggingParams(StackTraceLogType.Full);
                    }
                    else
                    {
                        SetScriptLoggingParams(StackTraceLogType.ScriptOnly);
                    }

                    if (SetGraphicsAPI(target) == false)                                                           // Check if Graphics API can be set to the specified target
                    {
                        Debug.LogError("Failed to build Player, Directory: " + directory + "/" + applicationName); // Log error
                        continue;                                                                                  // Go to next target
                    }

                    string build = BuildClient(target, directory, applicationName, config); // Build client
                    outputPath = directory;

                    while (UnityEditor.BuildPipeline.isBuildingPlayer == true)                      // Wait for build to finish
                    {
                        yield return(null);                                                         // Wait
                    }
                    if (build == "")                                                                // If build succeeded
                    {
                        Debug.Log("Built Player, Directory: " + directory + "/" + applicationName); // Log success
                    }
                    else // If build failed
                    {
                        Debug.LogError("Failed to build Player, Directory: " + directory + "/" + applicationName); // Log failure
                        Debug.LogError(build);                                                                     // Return build fail log
                    }
                }
                outputPath = outputPath.Replace(@"/", @"\");   // explorer doesn't like front slashes
                System.Diagnostics.Process.Start("explorer.exe", outputPath);
            }
            else // Null build configuartion
            {
                Debug.LogError("No Build Configuration file assigned. Please assign a Build Configuration file in the Build Pipeline window"); // Log error
            }
        }