Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 29 additions & 39 deletions Editor/ProfileEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,21 @@ public static bool Foldout(bool foldout, string content, GUIStyle style = null)
if (style == null) style = EditorStyles.foldout;

// Wrap foldout into a layout region to get the foldout's rect
var rect = EditorGUILayout.BeginHorizontal(GUIStyle.none);
var clicked = false;

// Determine if it is being clicked on the foldout before
// calling it to avoid it eating the event
if (Event.current.type == EventType.MouseUp
&& rect.Contains(Event.current.mousePosition)) {
clicked = true;
}
bool newFoldout = false;
bool clicked = false;
using (var rectScope = new EditorGUILayout.HorizontalScope(GUIStyle.none))
{
var rect = rectScope.rect;

var newFoldout = EditorGUILayout.Foldout(foldout, content, style);
// Determine if it is being clicked on the foldout before
// calling it to avoid it eating the event
if (Event.current.type == EventType.MouseUp
&& rect.Contains(Event.current.mousePosition)) {
clicked = true;
}

EditorGUILayout.EndHorizontal();
newFoldout = EditorGUILayout.Foldout(foldout, content, style);
}

// Act in case we saw a click but the foldout didn't toggle
if (newFoldout == foldout && clicked) {
Expand All @@ -142,7 +144,7 @@ public static bool Foldout(bool foldout, string content, GUIStyle style = null)
/// </summary>
public static bool Foldout(string path, bool def, string content, GUIStyle style = null)
{
EditorGUI.BeginChangeCheck();
using var _ = new EditorGUI.ChangeCheckScope();

var wasExpanded = EditorProfile.Instance.IsExpanded(path);
if (def) wasExpanded = !wasExpanded;
Expand Down Expand Up @@ -474,7 +476,7 @@ void InitializeGUI()
void SourceProfileGUI()
{
if (editorProfile != null) {
EditorGUILayout.BeginHorizontal();
using (new EditorGUILayout.HorizontalScope())
{
if (sourceProfiles == null) {
sourceProfiles = BuildProfile.AllBuildProfiles.Prepend(null).ToArray();
Expand All @@ -501,7 +503,6 @@ void SourceProfileGUI()
}
GUI.enabled = true;
}
EditorGUILayout.EndHorizontal();
}
}

Expand All @@ -525,7 +526,7 @@ protected void BuildGUI()
EditorGUILayout.Space();

var usesActive = buildProfile.UsesActiveBuildTarget();
EditorGUILayout.BeginHorizontal();
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.Label("Build Targets", boldLabel);
if (GUILayout.Button(GUIContent.none, plusStyle)) {
Expand All @@ -544,11 +545,10 @@ protected void BuildGUI()
}
GUILayout.FlexibleSpace();
}
EditorGUILayout.EndHorizontal();

foreach (var target in buildProfile.BuildTargets) {
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginDisabledGroup(usesActive);
using var _ = new EditorGUILayout.HorizontalScope();
using (new EditorGUI.DisabledGroupScope(usesActive))
{
if (GUILayout.Button(GUIContent.none, minusStyle)) {
delayedRemovals.Add(() => {
Expand All @@ -557,35 +557,30 @@ protected void BuildGUI()
}
EditorGUILayout.LabelField(target.ToString());
}
EditorGUI.EndDisabledGroup();

var path = buildProfile.GetLastBuildPath(target);
if (!string.IsNullOrEmpty(path)
&& (File.Exists(path) || Directory.Exists(path))
&& GUILayout.Button("Show", EditorStyles.miniButton, GUILayout.ExpandWidth(false))) {
EditorUtility.RevealInFinder(path);
}
EditorGUI.BeginDisabledGroup(BuildRunner.Current != null);
using (new EditorGUI.DisabledGroupScope(BuildRunner.Current != null))
{
if (GUILayout.Button("Build", EditorStyles.miniButton, GUILayout.ExpandWidth(false))) {
BuildManager.Build(buildProfile, target);
}
}
EditorGUI.EndDisabledGroup();

EditorGUILayout.EndHorizontal();
}

EditorGUILayout.Space();

EditorGUI.BeginDisabledGroup(BuildRunner.Current != null);
using (new EditorGUI.DisabledGroupScope(BuildRunner.Current != null))
{
var count = buildProfile.BuildTargets.Count();
if (GUILayout.Button("Build " + count + " Target" + (count > 1 ? "s" : ""), EditorStyles.miniButton)) {
BuildManager.Build(buildProfile);
}
}
EditorGUI.EndDisabledGroup();
}

protected void AddBuildTarget(object userData)
Expand Down Expand Up @@ -673,12 +668,11 @@ protected bool OptionGUI(Option option, int depth, bool showDefaultVariant = fal
}

if (category != lastCategory) {
EditorGUILayout.BeginHorizontal(categoryBackground);
using (new EditorGUILayout.HorizontalScope(categoryBackground))
{
var path = pathBase + "_" + category;
categoryExpanded = Foldout(path, true, category, categoryFoldout);
}
EditorGUILayout.EndHorizontal();
lastCategory = category;
} else if (categoryExpanded) {
GUILayout.Label(GUIContent.none, separator);
Expand All @@ -691,8 +685,10 @@ protected bool OptionGUI(Option option, int depth, bool showDefaultVariant = fal

// Option GUI
var lineHeight = EditorGUIUtility.singleLineHeight + linePadding;
var rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(lineHeight));
Rect rect;
using (var rectScope = new EditorGUILayout.HorizontalScope(GUILayout.Height(lineHeight)))
{
rect = rectScope.rect;
// Variant container
if (option.IsDefaultVariant && !showDefaultVariant) {
EditorGUILayout.LabelField(displayName, width);
Expand All @@ -707,9 +703,9 @@ protected bool OptionGUI(Option option, int depth, bool showDefaultVariant = fal

if (option.Variance == OptionVariance.Dictionary) {
// Disable when editing the default variant
EditorGUI.BeginDisabledGroup(isDefault);
using (new EditorGUI.DisabledGroupScope(isDefault))
{
EditorGUI.BeginDisabledGroup(isDefault);
using (new EditorGUI.DisabledGroupScope(isDefault))
{
var newParam = EditorGUILayout.DelayedTextField(option.VariantParameter, width);
if (newParam != option.VariantParameter) {
Expand All @@ -721,9 +717,7 @@ protected bool OptionGUI(Option option, int depth, bool showDefaultVariant = fal
Option.changed = true;
}
}
EditorGUI.EndDisabledGroup();
}
EditorGUI.EndDisabledGroup();
} else {
EditorGUILayout.PrefixLabel(" ");
}
Expand Down Expand Up @@ -759,7 +753,7 @@ protected bool OptionGUI(Option option, int depth, bool showDefaultVariant = fal
color.a = 1;
GUI.color = color;

EditorGUILayout.BeginHorizontal(includeBackground, GUILayout.Width(buildColumnWidth), GUILayout.Height(lineHeight));
using (new EditorGUILayout.HorizontalScope(includeBackground, GUILayout.Width(buildColumnWidth), GUILayout.Height(lineHeight)))
{
if (
buildProfile != null
Expand All @@ -769,25 +763,21 @@ protected bool OptionGUI(Option option, int depth, bool showDefaultVariant = fal
|| (option.Capabilities & OptionCapabilities.HasAssociatedFeature) != 0
)
) {
EditorGUI.BeginDisabledGroup(!optionAvailable);
using var _ = new EditorGUI.DisabledGroupScope(!optionAvailable);
var root = buildProfile.Store.GetOrCreateRoot(option.Name);
GUILayout.Label(LabelForInclusion(root, option.Capabilities), inclusionLabel);
if (optionAvailable) {
DoInclusionMenu(root, option.Capabilities);
}
EditorGUI.EndDisabledGroup();
} else {
EditorGUILayout.Space();
}
}
EditorGUILayout.EndHorizontal();
} else {
// Not including a layout group here somehow makes the parent group taller
EditorGUILayout.BeginHorizontal(GUILayout.Width(0));
EditorGUILayout.EndHorizontal();
using var _ = new EditorGUILayout.HorizontalScope(GUILayout.Width(0));
}
}
EditorGUILayout.EndHorizontal();

// Expansion toggle
if (expandable) {
Expand Down