Пример #1
0
 protected BuildSettings CreateBuildSettingsAssetWith(params IBuildSettingsComponent[] components)
 {
     return(BuildSettings.CreateAsset(GetRandomTestAssetPath(BuildSettings.AssetExtension), (settings) =>
     {
         foreach (var component in components)
         {
             settings.SetComponent(component.GetType(), component);
         }
     }));
 }
Пример #2
0
        public static BuildSettings CreateNewBuildSettingsAsset(string prefix, params IBuildSettingsComponent[] components)
        {
            var dependency = Selection.activeObject as BuildSettings;
            var path       = CreateAssetPathInActiveDirectory(prefix + $"BuildSettings{BuildSettings.AssetExtension}");

            return(BuildSettings.CreateAsset(path, (bs) =>
            {
                if (dependency != null)
                {
                    bs.AddDependency(dependency);
                }
                bs.SetComponent(new GeneralSettings());
                bs.SetComponent(new SceneList());
                foreach (var component in components)
                {
                    bs.SetComponent(component.GetType(), component);
                }
            }));
        }
        public IEnumerator CanBuildMultipleBuildsWithActiveTargetSwitch()
        {
            m_BuildPipeline = BuildPipeline.CreateAsset(k_TestBuildBuildpipelineAssetPath,
                                                        (p) =>
            {
                p.BuildSteps.Add(new TestBuildStepSuccess());
            });

            m_SettingsWindows32 = BuildSettings.CreateAsset(k_TestBuildSettings32AssetPath, (bs) =>
            {
                bs.SetComponent(new ClassicBuildProfile()
                {
                    Target   = Standalone32Target,
                    Pipeline = m_BuildPipeline
                });
            });

            m_SettingsWindows64 = BuildSettings.CreateAsset(k_TestBuildSettings64AssetPath, (bs) =>
            {
                bs.SetComponent(new ClassicBuildProfile()
                {
                    Target   = Standalone64Target,
                    Pipeline = m_BuildPipeline
                });
            });

            m_Container           = ResultContainer.CreateInstance <ResultContainer>();
            m_Container.Results   = null;
            m_Container.Completed = false;
            AssetDatabase.CreateAsset(m_Container, k_TestsContainer);
            AssetDatabase.ImportAsset(k_TestsContainer, ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);
            m_Container = AssetDatabase.LoadAssetAtPath <ResultContainer>(k_TestsContainer);

            m_OriginalBuildTarget      = EditorUserBuildSettings.activeBuildTarget;
            m_OriginalBuildTargetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(m_OriginalBuildTarget);

            // Leave this for testing purposes
            //if (EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, UnityEditor.BuildTarget.Android))
            //    yield return new RecompileScripts(false);

            var serttingsToBuilds = new[] { m_SettingsWindows32, m_SettingsWindows64 };

            BuildPipelineExtensions.BuildAsync(new BuildBatchDescription()
            {
                BuildItems = serttingsToBuilds.Select(m => new BuildBatchItem()
                {
                    BuildSettings = m
                }).ToArray(),
                OnBuildCompleted = m_Container.SetCompleted
            });

            while (m_Container.Completed == false)
            {
                yield return(new RecompileScripts(false));
            }

            Assert.IsTrue(EditorUserBuildSettings.activeBuildTarget == m_OriginalBuildTarget);
            Assert.IsTrue(m_Container.Results != null);
            Assert.IsTrue(m_Container.Results.Contains(m_SettingsWindows32.name + ", Success"));
            Assert.IsTrue(m_Container.Results.Contains(m_SettingsWindows64.name + ", Success"));
        }