Example #1
0
 private void DrawBuildOptions(BuildConfig config)
 {
     DrawBuildOption(config, BuildOptions.Development, "Development");
     DrawBuildInfo("Build a development version of the player.");
     DrawBuildOption(config, BuildOptions.AutoRunPlayer, "Auto Run Player");
     DrawBuildInfo("Run the built player.");
     DrawBuildOption(config, BuildOptions.ShowBuiltPlayer, "Show Built Player");
     DrawBuildInfo("Show the built player.");
     DrawBuildOption(config, BuildOptions.BuildAdditionalStreamedScenes, "Build Additional Streamed Scenes");
     DrawBuildInfo("Build a compressed asset bundle that contains streamed Scenes loadable with the UnityWebRequest class.");
     DrawBuildOption(config, BuildOptions.AcceptExternalModificationsToPlayer, "Accept External Modifications To Player");
     DrawBuildInfo("Used when building Xcode (iOS) or Eclipse (Android) projects.");
     DrawBuildOption(config, BuildOptions.InstallInBuildFolder, "Install In Build Folder");
     DrawBuildInfo("Copy UnityObject.js alongside Web Player so it wouldn't have to be downloaded from internet.");
     DrawBuildOption(config, BuildOptions.ConnectWithProfiler, "Connect With Profiler");
     DrawBuildInfo("Start the player with a connection to the profiler in the editor.");
     DrawBuildOption(config, BuildOptions.AllowDebugging, "Allow Debugging");
     DrawBuildInfo("Allow script debuggers to attach to the player remotely.");
     DrawBuildOption(config, BuildOptions.SymlinkLibraries, "Symlink Libraries");
     DrawBuildInfo("Symlink runtime libraries when generating iOS Xcode project. (Faster iteration time).");
     DrawBuildOption(config, BuildOptions.UncompressedAssetBundle, "Uncompressed Asset Bundle");
     DrawBuildInfo("Don't compress the data when creating the asset bundle.");
     DrawBuildOption(config, BuildOptions.ConnectToHost, "Connect To Host");
     DrawBuildInfo("Sets the Player to connect to the Editor.");
     DrawBuildOption(config, BuildOptions.EnableHeadlessMode, "Enable Headless Mode");
     DrawBuildInfo("Options for building the standalone player in headless mode.");
     DrawBuildOption(config, BuildOptions.BuildScriptsOnly, "Build Scripts Only");
     DrawBuildInfo("Only build the scripts in a Project.");
     DrawBuildOption(config, BuildOptions.PatchPackage, "Patch Package");
     DrawBuildInfo("Patch a Development app package rather than completely rebuilding it.");
     DrawBuildOption(config, BuildOptions.ForceEnableAssertions, "Force Enable Assertions");
     DrawBuildInfo("Include assertions in the build. By default, the assertions are only included in development builds.");
     DrawBuildOption(config, BuildOptions.CompressWithLz4, "Compress With Lz4");
     DrawBuildInfo("Use chunk-based LZ4 compression when building the Player.");
     DrawBuildOption(config, BuildOptions.CompressWithLz4HC, "Compress With Lz4HC");
     DrawBuildInfo("Use chunk-based LZ4 high-compression when building the Player.");
     DrawBuildOption(config, BuildOptions.ComputeCRC, "Compute CRC");
     DrawBuildInfo("Request that the CRC of the built output be computed and included in the build report.");
     DrawBuildOption(config, BuildOptions.StrictMode, "Strict Mode");
     DrawBuildInfo("Do not allow the build to succeed if any errors are reporting during it.");
     DrawBuildOption(config, BuildOptions.IncludeTestAssemblies, "Include Test Assemblies");
     DrawBuildInfo("Build will include Assemblies for testing.");
     DrawBuildOption(config, BuildOptions.NoUniqueIdentifier, "No Unique Identifier");
     DrawBuildInfo("Will force the build GUID to all zeros.");
     DrawBuildOption(config, BuildOptions.WaitForPlayerConnection, "Wait For Player Connection");
     DrawBuildInfo("Sets the Player to wait for player connection on player start.");
     DrawBuildOption(config, BuildOptions.EnableCodeCoverage, "Enable Code Coverage");
     DrawBuildInfo("Enables code coverage. You can use this as a complimentary way of enabling code coverage on platforms that do not support command line arguments.");
     DrawBuildOption(config, BuildOptions.EnableDeepProfilingSupport, "Enable Deep Profiling Support");
     DrawBuildInfo("Enables Deep Profiling support in the player.");
 }
Example #2
0
        private void DrawBuildOption(BuildConfig config, BuildOptions option, string label)
        {
            var value = (config.options & option) > 0;

            value = EditorGUILayout.ToggleLeft(label, value);

            if (value)
            {
                config.options |= option;
            }
            else
            {
                config.options &= ~option;
            }
        }
Example #3
0
        private void OnGUI()
        {
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(true));
            leftPos = EditorGUILayout.BeginScrollView(leftPos, GUILayout.Width(250));

            if (list == null)
            {
                list = new ReorderableList(configs, typeof(BuildConfig));
                list.drawHeaderCallback += (rect) =>
                {
                    GUI.Label(rect, "Build Configs");
                };
                list.drawElementCallback += (rect, index, active, focused) =>
                {
                    GUI.Label(rect, ((BuildConfig)list.list[index]).folder);
                };
                list.onAddCallback += (list) =>
                {
                    var config = new BuildConfig();
                    config.folder = "New Build Config";
                    list.list.Add(config);
                };
            }
            list.DoLayoutList();

            if (GUILayout.Button("Build Defaults"))
            {
                BuildDefaults();
            }
            if (GUILayout.Button("Open Build Folder"))
            {
                OpenBuildFolder();
            }

            GUILayout.EndScrollView();
            rightPos = GUILayout.BeginScrollView(rightPos);

            if (list.index >= 0)
            {
                var config = (BuildConfig)list.list[list.index];
                DrawConfig(config);
            }
            else
            {
                GUI.enabled = false;
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                EditorGUILayout.BeginVertical();
                EditorGUILayout.Space(20);
                GUILayout.Label("No build selected");
                EditorGUILayout.EndVertical();
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                GUI.enabled = true;
            }

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndHorizontal();

            GUI.enabled = false;
            GUILayout.Label(BuildUtil.GetSettingsPath());
            GUI.enabled = true;

            EditorGUILayout.EndVertical();

            if (EditorGUI.EndChangeCheck())
            {
                configs = (List <BuildConfig>)list.list;
                BuildUtil.SaveSettings(configs);
            }
        }
Example #4
0
        /// <summary>
        /// Builds the specified config.
        /// </summary>
        /// <param name="config">The build config to use.</param>
        public static void Build(BuildConfig config)
        {
            if (!IsTargetSupported(config.target))
            {
                Debug.LogError(string.Format(
                                   "Failed to build {0}; {0} build module is not installed",
                                   config.target
                                   ));

                return;
            }

            // Do the build
            var path    = Path.Combine(GetBuildPath(), config.folder);
            var options = new BuildPlayerOptions();

            options.target = config.target;
            options.scenes = EditorBuildSettings.scenes.Select(x => x.path).ToArray();

            switch (config.target)
            {
            // The WebGL build treats the locationPathName as the folder the
            // build will be generated in instead of the name of the
            // executable, which will always be index.html
            case BuildTarget.WebGL:
                options.locationPathName = path;
                break;

            default:
                options.locationPathName = Path.Combine(path,
                                                        GetExeFilename(config.exeName, config.target));
                break;
            }

            try
            {
                if (Directory.Exists(path))
                {
                    Directory.Delete(path, true);
                }
                BuildPipeline.BuildPlayer(options);
            }
            catch (Exception e)
            {
                Debug.LogError(string.Format(
                                   "Failed to build {0}; {1}",
                                   config.folder, e));
                return;
            }

            // Compress the build
            try
            {
                switch (config.target)
                {
                // Instead of zipping the entire folder, zip each item in
                // the folder instead for the Web build. This is because
                // itch.io expects the index.html file to be in the root
                // directory of the zipped build.
                case BuildTarget.WebGL:
                    var zipFilename = path + ".zip";
                    if (File.Exists(zipFilename))
                    {
                        File.Delete(zipFilename);
                    }

                    using (var zip = ZipStorer.Create(zipFilename))
                    {
                        var directories = Directory.GetDirectories(path);
                        foreach (var directory in directories)
                        {
                            zip.AddDirectory(
                                ZipStorer.Compression.Deflate,
                                directory, ""
                                );
                        }

                        var files = Directory.GetFiles(path);
                        foreach (var file in files)
                        {
                            zip.AddFile(
                                ZipStorer.Compression.Deflate,
                                file,
                                Path.GetFileName(file)
                                );
                        }
                    }
                    break;

                case BuildTarget.StandaloneWindows:
                case BuildTarget.StandaloneWindows64:
                    var zf = path + ".zip";
                    if (File.Exists(zf))
                    {
                        File.Delete(zf);
                    }

                    using (var zip = ZipStorer.Create(zf))
                    {
                        zip.AddDirectory(
                            ZipStorer.Compression.Deflate,
                            path, ""
                            );
                    }
                    break;

                default:
                    var archivePath = path + ".tar.gz";
                    if (File.Exists(archivePath))
                    {
                        File.Delete(archivePath);
                    }

                    using (var stream = new GZipOutputStream(File.Create(archivePath)))
                    {
                        using (var archive = TarArchive.CreateOutputTarArchive(stream, TarBuffer.DefaultBlockFactor))
                        {
                            TarCompress(new DirectoryInfo(path), archive);
                        }
                    }
                    break;
                }
            }
            catch (Exception e)
            {
                Debug.LogError(string.Format(
                                   "Failed to zip {0}; {1}",
                                   config.folder, e));
                return;
            }
        }