Skip to content

Commit 647c9df

Browse files
committed
fix: Disable the dropdowns for deployment settings until there are valid options to select from.
1 parent fe41eb3 commit 647c9df

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

Assets/Plugins/Source/Editor/Utility/GUIEditorUtility.cs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,13 @@ public static EOSClientCredentials RenderInput(ConfigFieldAttribute configFieldA
10791079
int currentIndex = 0;
10801080
foreach (Named<EOSClientCredentials> cred in credentials)
10811081
{
1082+
// Do not display incomplete client credentials as options
1083+
// for selection
1084+
if (!cred.Value.IsComplete)
1085+
{
1086+
continue;
1087+
}
1088+
10821089
if (cred.Value.Equals(value))
10831090
{
10841091
selectedIndex = currentIndex;
@@ -1089,11 +1096,22 @@ public static EOSClientCredentials RenderInput(ConfigFieldAttribute configFieldA
10891096
currentIndex++;
10901097
}
10911098

1099+
string additionalTooltip = "";
1100+
// If there are no credentials to select, then disable the popup.
1101+
if (credentialsLabels.Count == 0)
1102+
{
1103+
additionalTooltip =
1104+
"\nTo select a client credential for this platform, you must first add a valid one above.";
1105+
GUI.enabled = false;
1106+
}
1107+
10921108
int newIndex = EditorGUILayout.Popup(
1093-
CreateGUIContent(configFieldAttribute.Label, configFieldAttribute.ToolTip),
1109+
CreateGUIContent(configFieldAttribute.Label, configFieldAttribute.ToolTip + additionalTooltip),
10941110
selectedIndex,
10951111
credentialsLabels.ToArray());
10961112

1113+
GUI.enabled = true;
1114+
10971115
return (newIndex >= 0 && newIndex < credentials.Count) ? credentials[newIndex].Value : value;
10981116
});
10991117
}
@@ -1155,6 +1173,13 @@ public static Deployment RenderInput(ConfigFieldAttribute configFieldAttribute,
11551173
int currentIndex = 0;
11561174
foreach (Named<Deployment> deployment in deployments)
11571175
{
1176+
// Do not display incomplete deployments as options for
1177+
// selection.
1178+
if (!deployment.Value.IsComplete)
1179+
{
1180+
continue;
1181+
}
1182+
11581183
if (value.DeploymentId == deployment.Value.DeploymentId)
11591184
selectedIndex = currentIndex;
11601185

@@ -1163,11 +1188,23 @@ public static Deployment RenderInput(ConfigFieldAttribute configFieldAttribute,
11631188
currentIndex++;
11641189
}
11651190

1191+
// If there are no deployments to select, don't enable the
1192+
// popup.
1193+
string additionalTooltip = "";
1194+
if (deploymentLabels.Count == 0)
1195+
{
1196+
additionalTooltip = "\nTo select a deployment, you must define a valid one above.";
1197+
GUI.enabled = false;
1198+
}
1199+
11661200
int newIndex = EditorGUILayout.Popup(
1167-
CreateGUIContent(configFieldAttribute.Label, configFieldAttribute.ToolTip),
1201+
CreateGUIContent(configFieldAttribute.Label, configFieldAttribute.ToolTip + additionalTooltip),
11681202
selectedIndex,
11691203
deploymentLabels.ToArray());
11701204

1205+
// Re-enable the GUI
1206+
GUI.enabled = true;
1207+
11711208
return (newIndex >= 0 && newIndex < deployments.Count) ? deployments[newIndex].Value : value;
11721209
});
11731210
}

0 commit comments

Comments
 (0)