protected override TreeViewItem BuildRoot() { var idsToExpand = new List <int>(); var root = new TreeViewItem { id = int.MaxValue, depth = -1, displayName = "Root" }; List <BuildConfiguration> buildConfigurations = new List <BuildConfiguration>(); buildConfigurations.AddRange(s_BuildConfigurations); Dictionary <RootAssemblyInfo, RootAssemblyConfigInfo> configMap = new Dictionary <RootAssemblyInfo, RootAssemblyConfigInfo>(); foreach (var buildConfig in buildConfigurations) { bool hasRequiredComponents = true; hasRequiredComponents &= buildConfig.TryGetComponent(typeof(DotsRuntimeBuildProfile), out var buildProfile); hasRequiredComponents &= buildConfig.TryGetComponent(typeof(DotsRuntimeRootAssembly), out var buildTarget); if (hasRequiredComponents) { var dotsrtBuildProfile = (DotsRuntimeBuildProfile)buildProfile; var dotsrtRootAssembly = (DotsRuntimeRootAssembly)buildTarget; if (dotsrtBuildProfile.Target.CanBuild) { var rootAssemblyInfo = new RootAssemblyInfo(dotsrtRootAssembly.ProjectName); if (!configMap.TryGetValue(rootAssemblyInfo, out var configInfo)) { configInfo = new RootAssemblyConfigInfo(); configMap.Add(rootAssemblyInfo, configInfo); } configInfo.BuildConfigurations.Add(buildConfig); } } } #if DOTS_TEST_RUNNER var testTargets = GetTestTargets(); foreach (var target in testTargets) { var rootAssemblyInfo = new RootAssemblyInfo(target.RootAssembly.name); if (!configMap.TryGetValue(rootAssemblyInfo, out var configInfo)) { configInfo = new RootAssemblyConfigInfo(); configMap.Add(rootAssemblyInfo, configInfo); } configInfo.RuntimeTestTargets.Add(target); } #endif foreach (var assemblyInfo in configMap.Keys) { var configInfo = configMap[assemblyInfo]; if (configInfo.HasConfigs()) { var projectViewItem = new RootAssemblyViewItem(assemblyInfo); root.AddChild(projectViewItem); bool includeAllInSolution = true; bool expandParent = false; foreach (var buildConfig in configInfo.BuildConfigurations) { var configViewItem = new BuildConfigViewItem(buildConfig); includeAllInSolution &= configViewItem.IncludeInSolution; expandParent |= configViewItem.IncludeInSolution; projectViewItem.AddChild(configViewItem); } #if DOTS_TEST_RUNNER foreach (var target in configInfo.RuntimeTestTargets) { var configViewItem = new RuntimeTestTargetConfigViewItem(target); includeAllInSolution &= configViewItem.IncludeInSolution; expandParent |= configViewItem.IncludeInSolution; projectViewItem.AddChild(configViewItem); } #endif projectViewItem.IncludeAllInSolution = includeAllInSolution; if (expandParent) { idsToExpand.Add(projectViewItem.id); } } } if (!root.hasChildren) { root.AddChild(new TreeViewItem(0, 0, "No BuildConfiguration Assets Found in Project.")); } SetupDepthsFromParentsAndChildren(root); SetExpanded(idsToExpand); return(root); }
void DrawRowCell(Rect rect, Column column, RootAssemblyViewItem viewItem, RowGUIArgs args) { CenterRectUsingSingleLineHeight(ref rect); switch (column) { case Column.IncludeInSolutionToggle: { var toggleRect = rect; int toggleWidth = 20; toggleRect.x += rect.width * 0.5f - toggleWidth * 0.5f; bool allChildrenChecked = true; bool anyChildrenChecked = false; foreach (var child in args.item.children) { var buildConfigViewItem = child as ConfigViewItem; if (buildConfigViewItem != null) { allChildrenChecked &= buildConfigViewItem.IncludeInSolution; anyChildrenChecked |= buildConfigViewItem.IncludeInSolution; } } bool isMixed = !allChildrenChecked && anyChildrenChecked; bool originalIncludeAllInSolutionValue = viewItem.IncludeAllInSolution; EditorGUI.showMixedValue = isMixed; var toggleValue = EditorGUI.Toggle(toggleRect, viewItem.IncludeAllInSolution); if (toggleValue != viewItem.IncludeAllInSolution) { viewItem.IncludeAllInSolution = toggleValue; EditorGUI.showMixedValue = false; // If the parent and children are all selected, and the user de-selects // a child, don't unset all other children, but allow the parent to be listed // as mixed (which is equivalent to false, so setting via toggleValue is no longer ok) if (!(originalIncludeAllInSolutionValue && !toggleValue && isMixed)) { foreach (var child in args.item.children) { if (child is ConfigViewItem buildConfigViewItem) { buildConfigViewItem.IncludeInSolution = toggleValue; } } } Repaint(); } else { EditorGUI.showMixedValue = false; if (allChildrenChecked) { viewItem.IncludeAllInSolution = true; } } break; } case Column.RootGameAssembly: { DefaultGUI.Label(rect, viewItem.ProjectName, args.selected, args.focused); break; } } }