Skip to content

Commit

Permalink
feat: add app id field in setup guide
Browse files Browse the repository at this point in the history
  • Loading branch information
rYuuk committed Nov 6, 2023
1 parent ee4bd9e commit 4ac7b9c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
26 changes: 25 additions & 1 deletion Editor/UI/EditorWindows/SetupGuide/SetupGuide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public void CreateGUI()
StartStateMachine();
}

private string currentSubdomain;
private string currentAppId;

private VisualElement InitializeSubdomainPanel()
{
var headerLabel = rootVisualElement.Q<Label>(HEADER_LABEL);
Expand All @@ -72,8 +75,17 @@ private VisualElement InitializeSubdomainPanel()
var subdomainTemplate = subdomainPanel.Q<SubdomainTemplate>();
subdomainTemplate.OnSubdomainChanged += subdomain =>
{
nextButton.SetEnabled(!string.IsNullOrEmpty(subdomain));
currentSubdomain = subdomain;
ToggleNextButton();
};

var appIdTemplate = subdomainPanel.Q<AppIdTemplate>();
appIdTemplate.OnAppIdChanged += appId =>
{
currentAppId = appId;
ToggleNextButton();
};

if (!ProjectPrefs.GetBool(USE_DEMO_SUBDOMAIN_TOGGLE) && CoreSettingsHandler.CoreSettings.Subdomain == CoreSettings.DEFAULT_SUBDOMAIN)
{
subdomainTemplate.ClearSubdomain();
Expand Down Expand Up @@ -103,6 +115,18 @@ private VisualElement InitializeSubdomainPanel()
return subdomainPanel;
}

private void ToggleNextButton()
{
if (!string.IsNullOrEmpty(currentAppId) && !string.IsNullOrEmpty(currentSubdomain))
{
nextButton.SetEnabled(true);
}
else
{
nextButton.SetEnabled(false);
}
}

private VisualElement InitializeAnalyticsPanel()
{
var analyticsPanel = rootVisualElement.Q<VisualElement>(ANALYTICS_PANEL);
Expand Down
1 change: 1 addition & 0 deletions Editor/UI/EditorWindows/SetupGuide/SetupGuide.uxml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ui:Label tabindex="-1" text="(https://studio.readyplayer.me)" display-tooltip-when-elided="true" name="StudioUrl" class="link" style="margin-left: 15px; margin-right: 15px; white-space: normal; margin-top: 0; color: rgb(0, 104, 255);" />
</ui:VisualElement>
<ReadyPlayerMe.Core.Editor.SubdomainTemplate class="SubdomainTemplate" style="margin-top: 15px; flex-shrink: 0;" />
<ReadyPlayerMe.Core.Editor.AppIdTemplate style="flex-shrink: 0;" />
<ui:Toggle label="I don&apos;t have an account. Use demo subdomain instead." name="UseDemoSubdomainToggle" style="margin-left: 15px; margin-right: 15px; flex-direction: row-reverse; align-items: center; justify-content: space-between; align-self: flex-start; margin-top: 15px; margin-bottom: 15px; display: none;" />
</ui:VisualElement>
<ui:VisualElement name="AnalyticsPanel" style="flex-grow: 0; background-color: rgba(0, 0, 0, 0); margin-top: 0; height: 230px; flex-shrink: 0; display: flex; width: 500px;">
Expand Down
10 changes: 9 additions & 1 deletion Editor/UI/EditorWindows/Templates/AppIdTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using ReadyPlayerMe.Core.Analytics;
using UnityEngine;
using UnityEngine.UIElements;
Expand All @@ -16,9 +17,10 @@ public class AppIdTemplate : VisualElement
}

private readonly TextField appIdField;

private readonly string appId;

public event Action<string> OnAppIdChanged;

public AppIdTemplate()
{
var visualTree = Resources.Load<VisualTreeAsset>(XML_PATH);
Expand All @@ -31,6 +33,7 @@ public AppIdTemplate()
this.Q<Button>("AppIdHelpButton").clicked += OnAppIdHelpClicked;

appIdField.RegisterCallback<FocusOutEvent>(OnAppIdFocusOut);
appIdField.RegisterValueChangedCallback(OnAppIdValueChanged);
}

private static void OnAppIdHelpClicked()
Expand All @@ -47,6 +50,11 @@ private void OnAppIdFocusOut(FocusOutEvent _)
}
}

private void OnAppIdValueChanged(ChangeEvent<string> evt)
{
OnAppIdChanged?.Invoke(evt.newValue);
}

private bool ValidateAppId()
{
return !string.IsNullOrEmpty(appIdField.value);
Expand Down

0 comments on commit 4ac7b9c

Please sign in to comment.