internal static void OpenCSharpProject() { using (var progress = new ProgressBarScope("Generating DOTS C# Project", "Please wait...")) { var project = Application.AuthoringProject; var context = new BuildPipeline.BuildContext(new BuildSettings { Project = project, Platform = new DesktopDotNetPlatform(), Configuration = Configuration.Debug, OutputDirectory = Application.OutputDirectory }, progress); try { BuildProgramDataFileWriter.WriteAll(context.OutputDirectory.FullName); if (BuildStep.GenerateProjectFiles.Run(context)) { var dotsSolutionFile = Application.RootDirectory.GetFile($"{new NPath(Application.DataDirectory).Parent.FileName}-Dots.sln"); if (dotsSolutionFile.Exists) { Bridge.EditorApplication.OpenCSharpSolution(dotsSolutionFile); } } } catch (Exception e) { Debug.LogError($"Failed to generate DOTS C# project files.\n{e}"); } } }
public BuildContext(BuildSettings settings, ProgressBarScope progress) { BuildSettings = settings; ProgressBar = progress; WorldManager = Session.GetManager <IWorldManager>(); PersistenceManager = Session.GetManager <IPersistenceManager>(); OutputDirectory.EnsureExists(); DataDirectory.EnsureExists(); }
public bool Run(BuildPipeline.BuildContext context) { // FIXME: Have PackAllSpriteAtlases return whether or not any sprite // atlas needed packing, and refresh asset entity cache only if true. SpriteAtlasBridge.PackAllSpriteAtlases(); // Restore progress bar because pack sprite atlases will dispose it ProgressBarScope.Restore(); // Refresh all asset entities since packing sprite atlases might have changed the structure context.Session.GetManager <IAssetManagerInternal>().Refresh(); return(true); }
public static BuildResult Build(BuildSettings buildSettings) { if (UnityEditor.EditorApplication.isCompiling) { throw new InvalidOperationException("Building is not allowed while Unity is compiling."); } var buildSteps = new List <BuildStep.IBuildStep>() { BuildStep.PackAllSpriteAtlases, BuildStep.ExportAssets, BuildStep.ExportEntities, BuildStep.ExportConfiguration, BuildStep.GenerateBeeFiles, BuildStep.RunBee }; // Setup build steps per platform and configuration var platform = buildSettings.Platform; var configuration = buildSettings.Configuration; switch (configuration) { case Configuration.Debug: break; case Configuration.Develop: break; case Configuration.Release: break; default: throw new InvalidEnumArgumentException(nameof(configuration), (int)configuration, configuration.GetType()); } // Run build steps using (var progress = new ProgressBarScope($"Build {platform.ToString()} {configuration.ToString()}", "Building...")) { var results = RunBuildSteps(buildSteps.AsReadOnly(), new BuildContext(buildSettings, progress)); Analytics.SendBuildEvent(buildSettings.Project, results); return(results); } }
public static void Generate() { if (Application.isPlaying) { return; } const string title = "Generating property accessors"; using (var progressScope = new ProgressBarScope()) { EditorUtility.DisplayProgressBar(title, "", 0); #if UNITY_5_3_OR_NEWER var currentLevel = EditorSceneManager.GetActiveScene(); #else var currentLevel = EditorApplication.currentScene; #endif _contents = new StringBuilder(); _paths.Clear(); EditorUtility.DisplayProgressBar(title, "Creating header", 0); CreateHeader(_contents); var scenes = SelectedScenes; float total = scenes.Length + 1; for (int i = 0; i < scenes.Length; i++) { var level = scenes[i]; EditorUtility.DisplayProgressBar(title, "Opening scene " + level, i / total); #if UNITY_5_3_OR_NEWER var scene = EditorSceneManager.OpenScene(level); EditorSceneManager.SetActiveScene(scene); #else EditorApplication.OpenScene(level); #endif EditorUtility.DisplayProgressBar(title, "Adding paths in " + level, i / total); BuildPathsInScene(_contents); #if UNITY_5_3_OR_NEWER EditorSceneManager.CloseScene(scene, true); #endif } EditorUtility.DisplayProgressBar(title, "Generating for prefabs", total - 0.5f / total); GenForPrefabs(_contents); FinishContents(_contents); EditorUtility.DisplayProgressBar(title, "Reopening original", 1); #if UNITY_5_3_OR_NEWER EditorSceneManager.SetActiveScene(currentLevel); #endif var contents = _contents.ToString(); if (!ValidateContents(contents)) { var sw = new StreamWriter(CreateFile()); sw.Write(contents); FinishFile(sw); AssetDatabase.ImportAsset(_filePath.Replace(Application.dataPath, "Assets")); } ClearState(); EditorUtility.ClearProgressBar(); } }