Skip to content

Commit 3cbfcde

Browse files
authored
Merge pull request #1097 from PlayEveryWare/fix/auto-select-options-for-new-platforms
fix: Auto select deployment and client credentials for newly introduced platforms
2 parents 7d51446 + 40bf74d commit 3cbfcde

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

Assets/Plugins/Source/Editor/EditorWindows/EOSSettingsWindow.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,7 @@ protected override void RenderWindow()
235235

236236
if (_platformTabs != null && _platformConfigEditors.Count != 0)
237237
{
238-
var newlySelectedTabIndex = GUILayout.Toolbar(_selectedTab, _platformTabs, TAB_STYLE);
239-
240-
if (newlySelectedTabIndex != _selectedTab)
241-
{
242-
_selectedTab = newlySelectedTabIndex;
243-
}
238+
_selectedTab = GUILayout.Toolbar(_selectedTab, _platformTabs, TAB_STYLE);
244239

245240
GUILayout.Space(30);
246241

com.playeveryware.eos/Runtime/Core/Config/PlatformConfig.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,44 @@ protected override void OnReadCompleted()
270270
{
271271
base.OnReadCompleted();
272272

273+
// If the deployment and client credentials are complete, there is
274+
// nothing to do.
275+
if (deployment.IsComplete && clientCredentials is { IsComplete: true })
276+
{
277+
return;
278+
}
279+
280+
ProductConfig productConfig = Get<ProductConfig>();
281+
bool valuesImported = false;
282+
283+
if (!deployment.IsComplete &&
284+
productConfig.Environments.TryGetFirstDefinedNamedDeployment(out Named<Deployment> namedDeployment))
285+
{
286+
deployment = namedDeployment.Value;
287+
Debug.Log($"Platform {Platform} has no defined deployment, " +
288+
$"so one was selected: {namedDeployment}.");
289+
valuesImported = true;
290+
}
291+
292+
if (clientCredentials is not { IsComplete: true } &&
293+
productConfig.TryGetFirstCompleteNamedClientCredentials(
294+
out Named<EOSClientCredentials> namedCredentials))
295+
{
296+
clientCredentials = namedCredentials.Value;
297+
Debug.Log($"Platform {Platform} has no defined client " +
298+
$"credentials, so one was selected: " +
299+
$"{namedCredentials}.");
300+
valuesImported = true;
301+
}
302+
303+
// This compile conditional is here because writing configs to disk
304+
// is only allowed within the context of the unity editor.
305+
#if UNITY_EDITOR
306+
if (valuesImported)
307+
{
308+
Write();
309+
}
310+
#endif
273311
// If thread affinity is null then instantiate it.
274312
threadAffinity ??= new();
275313
}

0 commit comments

Comments
 (0)