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-573] Add show sample button in guide #141

Merged
merged 6 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Editor/Analytics/AmplitudeEditorLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ public void LogOpenOptimizationDocumentation()
LogEvent(Constants.EventName.OPEN_OPTIMIZATION_DOCUMENTATION);
}

public void LogSampleCreatorImported(string packageVersion)
public void LogAvatarCreatorSampleImported()
{
LogEvent(Constants.EventName.SAMPLE_CREATOR_IMPORTED);
LogEvent(Constants.EventName.AVATAR_CREATOR_SAMPLE_IMPORTED);
}

private void SetUserProperties()
Expand Down
2 changes: 1 addition & 1 deletion Editor/Analytics/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static class EventName
public const string OPEN_ANIMATION_DOCUMENTATION = "open animation documentation";
public const string OPEN_AVATAR_CREATOR_DOCUMENTATION = "open avatar creator documentation";
public const string OPEN_OPTIMIZATION_DOCUMENTATION = "open optimization documentation";
public const string SAMPLE_CREATOR_IMPORTED = "Sample creator present imported";
public const string AVATAR_CREATOR_SAMPLE_IMPORTED = "Avatar creator sample imported";
}

public static class Properties
Expand Down
1 change: 1 addition & 0 deletions Editor/Analytics/IAnalyticsEditorLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ public interface IAnalyticsEditorLogger
void LogOpenAnimationDocumentation();
void LogOpenAvatarCreatorDocumentation();
void LogOpenOptimizationDocumentation();
void LogAvatarCreatorSampleImported();
}
}
49 changes: 34 additions & 15 deletions Editor/UI/EditorWindows/IntegrationGuide/IntegrationGuide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public class IntegrationGuide : EditorWindow
private const string ADD_ANIMATIONS = "AddAnimations";
private const string INTEGRATE_AVATAR_CREATOR = "IntegrateAvatarCreator";
private const string OPTIMIZE_THE_PERFORMANCE = "OptimizeThePerformance";
private const string CORE_PACKAGE = "com.readyplayerme.core";
private const string QUICKSTART_SAMPLE_NAME = "QuickStart";
private const string AVATAR_CREATOR_SAMPLE_NAME = "AvatarCreatorSamples";
private const string AVATAR_CREATOR_SAMPLE_SCENE_NAME = "Scenes/AvatarCreatorSample";

[SerializeField] private VisualTreeAsset visualTreeAsset;

Expand All @@ -37,46 +41,61 @@ public void CreateGUI()
var headerLabel = rootVisualElement.Q<Label>(HEADER_LABEL);
headerLabel.text = INTEGRATION_GUIDE;

var quickStartButton = rootVisualElement.Q<VisualElement>(QUICK_START).Q<Button>();
quickStartButton.clicked += OnOpenQuickStartButton;
var loadAvatarsDocButton = rootVisualElement.Q<VisualElement>(LOAD_AVATARS).Q<Button>();
loadAvatarsDocButton.clicked += () =>
RegisterButtons();
}

private void RegisterButtons()
{
rootVisualElement.Q<VisualElement>(QUICK_START).Q<Button>().clicked += () =>
{
AnalyticsEditorLogger.EventLogger.LogLoadQuickStartScene();
LoadAndOpenSample(QUICKSTART_SAMPLE_NAME, QUICKSTART_SAMPLE_NAME);
};

rootVisualElement.Q<VisualElement>(LOAD_AVATARS).Q<Button>().clicked += () =>
{
AnalyticsEditorLogger.EventLogger.LogOpenAvatarDocumentation();
OpenDocumentation(LOAD_AVATARS_URL);
};

var addAnimationDocButton = rootVisualElement.Q<VisualElement>(ADD_ANIMATIONS).Q<Button>();
addAnimationDocButton.clicked += () =>
rootVisualElement.Q<VisualElement>(ADD_ANIMATIONS).Q<Button>().clicked += () =>
{
AnalyticsEditorLogger.EventLogger.LogOpenAnimationDocumentation();
OpenDocumentation(ADD_ANIMATION_URL);
};

var integrateAvatarCreatorDocButton = rootVisualElement.Q<VisualElement>(INTEGRATE_AVATAR_CREATOR).Q<Button>();
integrateAvatarCreatorDocButton.clicked += () =>
rootVisualElement.Q<VisualElement>(INTEGRATE_AVATAR_CREATOR).Q<Button>("SeeDocsButton").clicked += () =>
{
AnalyticsEditorLogger.EventLogger.LogOpenAvatarCreatorDocumentation();
OpenDocumentation(AVATAR_CREATOR_URL);
};

var optimizePerformanceDocButton = rootVisualElement.Q<VisualElement>(OPTIMIZE_THE_PERFORMANCE).Q<Button>();
optimizePerformanceDocButton.clicked += () =>
rootVisualElement.Q<VisualElement>(INTEGRATE_AVATAR_CREATOR).Q<Button>("LoadSampleSceneButton").clicked += () =>
{
AnalyticsEditorLogger.EventLogger.LogAvatarCreatorSampleImported();
LoadAndOpenSample(AVATAR_CREATOR_SAMPLE_NAME, AVATAR_CREATOR_SAMPLE_SCENE_NAME);
};

rootVisualElement.Q<VisualElement>(OPTIMIZE_THE_PERFORMANCE).Q<Button>().clicked += () =>
{
AnalyticsEditorLogger.EventLogger.LogOpenOptimizationDocumentation();
OpenDocumentation(OPTIMIZE_PERFORMANCE_URL);
};
}

private void OnOpenQuickStartButton()
private void LoadAndOpenSample(string sampleName, string scenePath)
{
Close();

if (!new QuickStartHelper().Open())
var sampleLoader = new SampleLoader();

if (sampleLoader.Load(CORE_PACKAGE, sampleName))
{
EditorUtility.DisplayDialog(INTEGRATION_GUIDE, "No quick start sample found.", "OK");
sampleLoader.OpenScene(scenePath);
return;
}
AnalyticsEditorLogger.EventLogger.LogLoadQuickStartScene();

EditorUtility.DisplayDialog(INTEGRATION_GUIDE, $"No sample with name {sampleName} found.", "OK");
}

private void OpenDocumentation(string link)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
<ui:VisualElement name="IntegrateAvatarCreator" class="box" style="flex-shrink: 0; -unity-background-scale-mode: stretch-to-fill; margin-left: 15px; margin-right: 7.5px; margin-top: 0; margin-bottom: 15px; flex-direction: column; align-items: flex-start; justify-content: space-around; width: 227.5px; height: 135px;">
<ui:Label text="Integrate the Avatar Creator" display-tooltip-when-elided="true" name="Heading" class="headingText" style="margin-left: 5px; margin-bottom: 10px; margin-top: 10px; margin-right: 5px; font-size: 14px;" />
<ui:Label text="Learn how to integrate the avatar creator in your app or game." display-tooltip-when-elided="true" name="Description" style="white-space: normal; margin-left: 5px; margin-right: 5px; -unity-text-align: upper-left;" />
<ui:Button text="See Docs" display-tooltip-when-elided="true" style="-unity-text-align: middle-center; white-space: nowrap; flex-direction: row-reverse; align-items: auto; justify-content: flex-start; border-left-width: 0; border-right-width: 0; border-top-width: 0; border-bottom-width: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; padding-left: 5px; padding-right: 5px; padding-top: 5px; padding-bottom: 5px; margin-top: 5px; margin-bottom: 5px; margin-right: 5px; margin-left: 5px;" />
<ui:VisualElement name="Buttons" style="flex-direction: row; align-items: stretch; justify-content: flex-start; flex-shrink: 0; margin-bottom: 0; margin-top: 0;">
<ui:Button text="See Docs" display-tooltip-when-elided="true" name="SeeDocsButton" style="-unity-text-align: middle-center; white-space: nowrap; flex-direction: row-reverse; align-items: auto; justify-content: flex-start; border-left-width: 0; border-right-width: 0; border-top-width: 0; border-bottom-width: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; padding-left: 5px; padding-right: 5px; padding-top: 5px; padding-bottom: 5px; margin-top: 5px; margin-bottom: 5px; margin-right: 5px; margin-left: 5px;" />
<ui:Button text="Load Sample Scene" display-tooltip-when-elided="true" name="LoadSampleSceneButton" style="-unity-text-align: middle-center; white-space: nowrap; flex-direction: row-reverse; align-items: auto; justify-content: flex-start; border-left-width: 0; border-right-width: 0; border-top-width: 0; border-bottom-width: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; padding-left: 5px; padding-right: 5px; padding-top: 5px; padding-bottom: 5px; margin-top: 5px; margin-bottom: 5px; margin-right: 5px; margin-left: 5px;" />
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="OptimizeThePerformance" class="box" style="flex-shrink: 0; -unity-background-scale-mode: stretch-to-fill; margin-left: 7.5px; margin-right: 15px; margin-top: 0; margin-bottom: 15px; flex-direction: column; align-items: flex-start; justify-content: space-around; width: 227.5px; height: 135px;">
<ui:Label text="Optimize the performance" display-tooltip-when-elided="true" name="Heading" class="headingText" style="margin-left: 5px; margin-bottom: 10px; margin-top: 10px; margin-right: 5px; font-size: 14px;" />
Expand Down
3 changes: 0 additions & 3 deletions Editor/UI/Obsolete.meta

This file was deleted.

98 changes: 0 additions & 98 deletions Editor/UI/Obsolete/AvatarConfigEditor.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Editor/UI/Obsolete/AvatarConfigEditor.cs.meta

This file was deleted.

Loading