public bool Run(BuildPipeline.BuildContext context)
 {
     BuildProgramDataFileWriter.WriteAll(context.OutputDirectory.FullName);
     WriteBeeExportManifestFile(context);
     WriteBeeBuildSettingsFile(context);
     return(true);
 }
Пример #2
0
            public bool Run(BuildPipeline.BuildContext context)
            {
                var assetEntities = AssetExporter.Export(context);

                if (assetEntities.Count == 0)
                {
                    return(true);
                }

                using (var tmpWorld = new World(AssetsScene.Guid.ToString("N")))
                {
                    // Copy asset entities into temporary world
                    foreach (var pair in assetEntities)
                    {
                        CopyEntity(pair.Value, context.World, tmpWorld);
                    }

                    // Export assets scene
                    var outputFile = context.DataDirectory.GetFile(tmpWorld.Name);
                    if (!ExportWorld(outputFile, context.Project, AssetsScene.Path, tmpWorld))
                    {
                        return(false);
                    }

                    // Update manifest
                    context.Manifest.Add(AssetsScene.Guid, AssetsScene.Path, outputFile.AsEnumerable());
                }

                return(true);
            }
Пример #3
0
            public bool Run(BuildPipeline.BuildContext context)
            {
                var commandOutput = new StringBuilder();
                var buildOutput   = new StringBuilder();
                var buildProgress = BeeTools.Run("ProjectFiles", commandOutput, buildOutput, context.OutputDirectory);

                while (buildProgress.MoveNext())
                {
                    context.ProgressBar?.Update(buildProgress.Current.Info, buildProgress.Current.Progress);
                }
                return(buildProgress.Current.ExitCode == 0);
            }
Пример #4
0
            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);
            }
            private static void WriteBeeBuildSettingsFile(BuildPipeline.BuildContext context)
            {
                var settings = context.Project.Settings;
                var file     = context.OutputDirectory.GetFile("buildsettings.json");

                file.UpdateAllText(JsonSerialization.Serialize(new BeeBuildSettings
                {
                    emscriptenLinkSettings = new BeeBuildSettings.EmscriptenLinkSettings
                    {
                        TOTAL_MEMORY = settings.WebSettings.MemorySizeInMB * 1024 * 1024
                    }
                }));
            }
            public bool Run(BuildPipeline.BuildContext context)
            {
                using (var tmpWorld = new World(ConfigurationScene.Guid.ToString("N")))
                {
                    var configEntity = CopyEntity(context.WorldManager.GetConfigEntity(), context.World, tmpWorld);

                    // Insert asset scene before all other startup scenes, if there's any asset
                    if (AssetEnumerator.GetAllReferencedAssets(context.Project).Count > 0)
                    {
                        Assert.IsTrue(tmpWorld.EntityManager.HasComponent <StartupScenes>(configEntity));
                        var startupScenes = tmpWorld.EntityManager.GetBuffer <StartupScenes>(configEntity).Reinterpret <Guid>();
                        if (startupScenes.Length == 0)
                        {
                            Debug.LogWarning($"Project {context.Project.Name} contains no startup scenes.");
                        }
                        startupScenes.Insert(0, AssetsScene.Guid);
                    }

                    // Make sure components not owned by the users are removed if their assemblies are missing
                    var configArchetype    = context.Session.GetManager <IArchetypeManager>().Config;
                    var componentsToRemove = GetAllComponentTypes(configArchetype).Where(t => !DomainCache.IsIncludedInProject(context.Project, t.GetManagedType()));
                    tmpWorld.EntityManager.RemoveComponent(tmpWorld.EntityManager.UniversalQuery, new ComponentTypes(componentsToRemove.ToArray()));

                    // Export configuration scene
                    var outputFile = context.DataDirectory.GetFile(tmpWorld.Name);
                    if (!ExportWorld(outputFile, context.Project, ConfigurationScene.Path, tmpWorld))
                    {
                        return(false);
                    }

                    // Update manifest
                    context.Manifest.Add(ConfigurationScene.Guid, ConfigurationScene.Path, outputFile.AsEnumerable());

                    // Dump debug file
                    var debugFile  = context.DataDirectory.GetFile(".debug.txt");
                    var debugLines = context.Manifest.Assets.OrderBy(x => x.Value).Select(x => $"{x.Key.ToString("N")} = {x.Value.DoubleQuoted()}");
                    debugFile.WriteAllLines(debugLines.ToArray());
                }

                return(true);
            }
Пример #7
0
 public bool IsEnabled(BuildPipeline.BuildContext context)
 {
     return(UnityEditor.AssetDatabase.FindAssets($"t:{typeof(UnityEngine.U2D.SpriteAtlas).Name}").Length > 0);
 }
Пример #8
0
 public bool IsEnabled(BuildPipeline.BuildContext context) => true;
            public bool Run(BuildPipeline.BuildContext context)
            {
                var scenes = context.Project.GetScenes();

                if (scenes.Length == 0)
                {
                    Debug.LogWarning($"Project {context.Project.Name} contains no scenes.");
                }

                var editorSceneManager = context.Session.GetManager <IEditorSceneManagerInternal>();

                foreach (var sceneReference in scenes)
                {
                    var assetGuid = sceneReference.SceneGuid;
                    var sceneName = context.PersistenceManager.GetSceneAssetName(assetGuid);
                    context.ProgressBar.Update($"{Description} for {sceneName}");

                    using (var tmpWorld = new World(assetGuid.ToString("N")))
                    {
                        // Scene asset path must exist in asset database
                        var assetPath = context.PersistenceManager.GetSceneAssetPath(assetGuid);
                        if (string.IsNullOrEmpty(assetPath))
                        {
                            Debug.LogError($"Could not locate asset path for asset guid {assetGuid.ToString("N")}.");
                            continue;
                        }

                        var scene = editorSceneManager.GetFirstInstanceOfSceneLoaded(assetGuid);
                        if (scene != Scene.Null)
                        {
                            // Copy scene entities into temporary world
                            using (var entities = scene.ToEntityArray(context.EntityManager, Collections.Allocator.TempJob))
                            {
                                foreach (var entity in entities)
                                {
                                    CopyEntity(entity, context.World, tmpWorld);
                                }
                            }
                        }
                        else
                        {
                            // Load scene into temporary world
                            scene = context.PersistenceManager.LoadScene(tmpWorld.EntityManager, assetPath, removeRemapInfo: false);
                            if (scene == Scene.Null)
                            {
                                Debug.LogError($"Failed to load scene at path '{assetPath}'.");
                                continue;
                            }
                        }

                        // Export scene
                        var outputFile = context.DataDirectory.GetFile(tmpWorld.Name);
                        if (!ExportWorld(outputFile, context.Project, assetPath, tmpWorld))
                        {
                            return(false);
                        }

                        // Update manifest
                        context.Manifest.Add(assetGuid, assetPath, outputFile.AsEnumerable());
                    }
                }

                return(true);
            }
Пример #10
0
            public bool Run(BuildPipeline.BuildContext context)
            {
                var commandOutput = new StringBuilder();
                var buildOutput   = new StringBuilder();

                const string commandExt =
#if UNITY_EDITOR_WIN
                    ".bat";
#else
                    ".sh";
#endif

                var result = false;
                try
                {
                    var buildProgress = BeeTools.Run(ResolveEditorToolsTargetName() + " " + context.BeeTargetName, commandOutput, buildOutput, context.OutputDirectory);
                    while (buildProgress.MoveNext())
                    {
                        context.ProgressBar?.Update(buildProgress.Current.Info, buildProgress.Current.Progress);
                    }

                    result = buildProgress.Current.ExitCode == 0;
                }
                finally
                {
                    // Write runbuild file
                    var runBuildFile = context.OutputDirectory.GetFile("runbuild" + commandExt);
                    runBuildFile.UpdateAllText(commandOutput.ToString());

                    // Write build log file
                    var buildLogFile = context.OutputDirectory.GetFile("build.log");
                    buildLogFile.WriteAllText(buildOutput.ToString(), Encoding.UTF8);

                    // Log build error to Unity console
                    if (!result)
                    {
                        if (buildLogFile.Exists)
                        {
                            var logLines  = buildLogFile.ReadAllLines(Encoding.UTF8);
                            var lineIndex = logLines.Length - 1;
                            for (; lineIndex >= 0; --lineIndex)
                            {
                                if (logLines[lineIndex] == "##### ExitCode")
                                {
                                    break;
                                }
                            }
                            var buildLogTail = new StringBuilder($"Build failed. Open {buildLogFile.FullName.HyperLink()} for more details.{Environment.NewLine}");
                            for (var i = Math.Max(0, lineIndex); i < logLines.Length; ++i)
                            {
                                buildLogTail.AppendLine(logLines[i]);
                            }
                            Debug.LogError(buildLogTail);
                        }
                        else
                        {
                            Debug.LogError("Build failed, no build.log file found.");
                        }
                    }
                }

                return(result);
            }
            private static void WriteBeeExportManifestFile(BuildPipeline.BuildContext context)
            {
                var file = context.ArtifactsDirectory.GetFile("export.manifest");

                file.UpdateAllLines(context.Manifest.ExportedFiles.Select(x => x.FullName).ToArray());
            }