Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-513] Add appid to setup guide #145

Merged
merged 2 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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