From 1620c752c9dca8c5dcc6238c87ac095531f1b2e5 Mon Sep 17 00:00:00 2001 From: Robin <1121080+rYuuk@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:33:37 +0100 Subject: [PATCH 1/6] feat: remove obselete scripts --- Editor/UI/Obsolete.meta | 3 - Editor/UI/Obsolete/AvatarConfigEditor.cs | 98 --------- Editor/UI/Obsolete/AvatarConfigEditor.cs.meta | 11 - .../UI/Obsolete/AvatarLoaderEditorWindow.cs | 195 ------------------ .../Obsolete/AvatarLoaderEditorWindow.cs.meta | 11 - Editor/UI/Obsolete/Components.meta | 8 - .../Components/DocumentationButton.cs | 35 ---- .../Components/DocumentationButton.cs.meta | 3 - Editor/UI/Obsolete/Components/Footer.cs | 55 ----- Editor/UI/Obsolete/Components/Footer.cs.meta | 11 - Editor/UI/Obsolete/Components/Header.cs | 42 ---- Editor/UI/Obsolete/Components/Header.cs.meta | 3 - .../Components/IEditorWindowComponent.cs | 6 - .../Components/IEditorWindowComponent.cs.meta | 11 - .../UI/Obsolete/Components/SubdomainField.cs | 147 ------------- .../Components/SubdomainField.cs.meta | 3 - Editor/UI/Obsolete/EditorWindowBase.cs | 101 --------- Editor/UI/Obsolete/EditorWindowBase.cs.meta | 11 - Editor/UI/Obsolete/Helpers.meta | 3 - .../UI/Obsolete/Helpers/AvatarConfigFields.cs | 169 --------------- .../Helpers/AvatarConfigFields.cs.meta | 3 - Editor/UI/Obsolete/Helpers/AvatarUrlField.cs | 110 ---------- .../Obsolete/Helpers/AvatarUrlField.cs.meta | 3 - .../Helpers/HeadingAndDescriptionField.cs | 52 ----- .../HeadingAndDescriptionField.cs.meta | 3 - Editor/UI/Obsolete/Layout.cs | 23 --- Editor/UI/Obsolete/Layout.cs.meta | 3 - Editor/UI/Obsolete/SettingsEditorWindow.cs | 179 ---------------- .../UI/Obsolete/SettingsEditorWindow.cs.meta | 11 - Editor/UI/Obsolete/SetupGuidePanels.meta | 3 - .../SetupGuidePanels/AnalyticsPanel.cs | 74 ------- .../SetupGuidePanels/AnalyticsPanel.cs.meta | 11 - .../SetupGuidePanels/AvatarConfigPanel.cs | 41 ---- .../AvatarConfigPanel.cs.meta | 3 - .../SetupGuidePanels/SubdomainPanel.cs | 75 ------- .../SetupGuidePanels/SubdomainPanel.cs.meta | 3 - Editor/UI/Obsolete/SetupGuideWindow.cs | 195 ------------------ Editor/UI/Obsolete/SetupGuideWindow.cs.meta | 11 - .../Helpers => Utils}/QuickStartHelper.cs | 0 .../QuickStartHelper.cs.meta | 0 40 files changed, 1729 deletions(-) delete mode 100644 Editor/UI/Obsolete.meta delete mode 100644 Editor/UI/Obsolete/AvatarConfigEditor.cs delete mode 100644 Editor/UI/Obsolete/AvatarConfigEditor.cs.meta delete mode 100644 Editor/UI/Obsolete/AvatarLoaderEditorWindow.cs delete mode 100644 Editor/UI/Obsolete/AvatarLoaderEditorWindow.cs.meta delete mode 100644 Editor/UI/Obsolete/Components.meta delete mode 100644 Editor/UI/Obsolete/Components/DocumentationButton.cs delete mode 100644 Editor/UI/Obsolete/Components/DocumentationButton.cs.meta delete mode 100644 Editor/UI/Obsolete/Components/Footer.cs delete mode 100644 Editor/UI/Obsolete/Components/Footer.cs.meta delete mode 100644 Editor/UI/Obsolete/Components/Header.cs delete mode 100644 Editor/UI/Obsolete/Components/Header.cs.meta delete mode 100644 Editor/UI/Obsolete/Components/IEditorWindowComponent.cs delete mode 100644 Editor/UI/Obsolete/Components/IEditorWindowComponent.cs.meta delete mode 100644 Editor/UI/Obsolete/Components/SubdomainField.cs delete mode 100644 Editor/UI/Obsolete/Components/SubdomainField.cs.meta delete mode 100644 Editor/UI/Obsolete/EditorWindowBase.cs delete mode 100644 Editor/UI/Obsolete/EditorWindowBase.cs.meta delete mode 100644 Editor/UI/Obsolete/Helpers.meta delete mode 100644 Editor/UI/Obsolete/Helpers/AvatarConfigFields.cs delete mode 100644 Editor/UI/Obsolete/Helpers/AvatarConfigFields.cs.meta delete mode 100644 Editor/UI/Obsolete/Helpers/AvatarUrlField.cs delete mode 100644 Editor/UI/Obsolete/Helpers/AvatarUrlField.cs.meta delete mode 100644 Editor/UI/Obsolete/Helpers/HeadingAndDescriptionField.cs delete mode 100644 Editor/UI/Obsolete/Helpers/HeadingAndDescriptionField.cs.meta delete mode 100644 Editor/UI/Obsolete/Layout.cs delete mode 100644 Editor/UI/Obsolete/Layout.cs.meta delete mode 100644 Editor/UI/Obsolete/SettingsEditorWindow.cs delete mode 100644 Editor/UI/Obsolete/SettingsEditorWindow.cs.meta delete mode 100644 Editor/UI/Obsolete/SetupGuidePanels.meta delete mode 100644 Editor/UI/Obsolete/SetupGuidePanels/AnalyticsPanel.cs delete mode 100644 Editor/UI/Obsolete/SetupGuidePanels/AnalyticsPanel.cs.meta delete mode 100644 Editor/UI/Obsolete/SetupGuidePanels/AvatarConfigPanel.cs delete mode 100644 Editor/UI/Obsolete/SetupGuidePanels/AvatarConfigPanel.cs.meta delete mode 100644 Editor/UI/Obsolete/SetupGuidePanels/SubdomainPanel.cs delete mode 100644 Editor/UI/Obsolete/SetupGuidePanels/SubdomainPanel.cs.meta delete mode 100644 Editor/UI/Obsolete/SetupGuideWindow.cs delete mode 100644 Editor/UI/Obsolete/SetupGuideWindow.cs.meta rename Editor/{UI/Obsolete/Helpers => Utils}/QuickStartHelper.cs (100%) rename Editor/{UI/Obsolete/Helpers => Utils}/QuickStartHelper.cs.meta (100%) diff --git a/Editor/UI/Obsolete.meta b/Editor/UI/Obsolete.meta deleted file mode 100644 index 2e7b5aa9..00000000 --- a/Editor/UI/Obsolete.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: b4f2c7f0bcab414f9ddaa69effc4f4b7 -timeCreated: 1689085277 \ No newline at end of file diff --git a/Editor/UI/Obsolete/AvatarConfigEditor.cs b/Editor/UI/Obsolete/AvatarConfigEditor.cs deleted file mode 100644 index e12fa17c..00000000 --- a/Editor/UI/Obsolete/AvatarConfigEditor.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System; -using ReadyPlayerMe.Core.Editor; -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core -{ - [Obsolete("Use AvatarConfigNewEditor instead")] - public class AvatarConfigEditor : UnityEditor.Editor - { - private const string USE_DRACO_COMPRESSION = "UseDracoCompression"; - private const string DIALOG_TITLE = "Read Player Me"; - private const string DIALOG_MESSAGE = "Do you want to install Draco Compression Unity Package: com.atteneder.draco ?"; - private const string DIALOG_OK = "Ok"; - private const string DIALOG_CANCEL = "Cancel"; - - private AvatarConfig avatarConfigTarget; - private SerializedProperty userDracoCompressionField; - - public override void OnInspectorGUI() - { - avatarConfigTarget = (AvatarConfig) target; - var previousValue = userDracoCompressionField.boolValue; - - DrawDefaultInspector(); - DrawMorphTargets(); - - if (!previousValue && userDracoCompressionField.boolValue) - { - if (!ModuleInstaller.IsModuleInstalled(ModuleList.DracoCompression.name)) - { - if (EditorUtility.DisplayDialog(DIALOG_TITLE, DIALOG_MESSAGE, DIALOG_OK, DIALOG_CANCEL)) - { - ModuleInstaller.AddModuleRequest(ModuleList.DracoCompression.Identifier); - } - else - { - userDracoCompressionField.boolValue = false; - serializedObject.ApplyModifiedProperties(); - } - } - } - } - - private void OnEnable() - { - userDracoCompressionField = serializedObject.FindProperty(USE_DRACO_COMPRESSION); - } - - private void DrawMorphTargets() - { - GUILayout.Space(5); - GUILayout.Label("Morph Targets", EditorStyles.boldLabel); - GUILayout.Space(3); - for (var i = 0; i < avatarConfigTarget.MorphTargets.Count; i++) - { - DrawMorphTarget(i); - } - DrawAddMorphTargetButton(); - } - - private void DrawMorphTarget(int targetIndex) - { - GUILayout.BeginHorizontal(); - { - EditorGUI.BeginChangeCheck(); - var index = AvatarMorphTarget.MorphTargetAvatarAPI.IndexOf(avatarConfigTarget.MorphTargets[targetIndex]); - var selected = EditorGUILayout.Popup(index, AvatarMorphTarget.MorphTargetAvatarAPI.ToArray()); - - if (EditorGUI.EndChangeCheck()) - { - Undo.RecordObject(avatarConfigTarget, "Modify Morph Target"); - avatarConfigTarget.MorphTargets[targetIndex] = AvatarMorphTarget.MorphTargetAvatarAPI[selected]; - EditorUtility.SetDirty(avatarConfigTarget); - } - - if (GUILayout.Button("Remove", GUILayout.Width(100))) - { - Undo.RecordObject(avatarConfigTarget, "Delete Morph Target"); - avatarConfigTarget.MorphTargets.RemoveAt(targetIndex); - EditorUtility.SetDirty(avatarConfigTarget); - } - } - GUILayout.EndHorizontal(); - } - - private void DrawAddMorphTargetButton() - { - GUILayout.Space(3); - if (GUILayout.Button("Add", GUILayout.Height(30))) - { - Undo.RecordObject(avatarConfigTarget, "Add Morph Target"); - avatarConfigTarget.MorphTargets.Add(AvatarMorphTarget.MorphTargetAvatarAPI[0]); - EditorUtility.SetDirty(avatarConfigTarget); - } - } - } -} diff --git a/Editor/UI/Obsolete/AvatarConfigEditor.cs.meta b/Editor/UI/Obsolete/AvatarConfigEditor.cs.meta deleted file mode 100644 index 810538dc..00000000 --- a/Editor/UI/Obsolete/AvatarConfigEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3c739418e5d294fd5bb8d5a1dfb0e539 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/UI/Obsolete/AvatarLoaderEditorWindow.cs b/Editor/UI/Obsolete/AvatarLoaderEditorWindow.cs deleted file mode 100644 index 6a8fdbb3..00000000 --- a/Editor/UI/Obsolete/AvatarLoaderEditorWindow.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System; -using ReadyPlayerMe.Core.Analytics; -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - [Obsolete("Use AvatarLoaderEditor instead")] - public class AvatarLoaderEditorWindow : EditorWindowBase - { - private const string VOICE_TO_ANIM_SAVE_KEY = "VoiceToAnimSaveKey"; - private const string EYE_ANIMATION_SAVE_KEY = "EyeAnimationSaveKey"; - private const string MODEL_CACHING_SAVE_KEY = "ModelCachingSaveKey"; - - private const string EDITOR_WINDOW_NAME = "avatar loader"; - private const string WINDOW_HEADING = "Avatar Loader"; - - private bool useVoiceToAnim; - private bool useEyeAnimations; - private bool initialized; - - private readonly GUILayoutOption fieldHeight = GUILayout.Height(20); - - private GUIStyle errorButtonStyle; - private GUIStyle avatarButtonStyle; - private GUIStyle parametersSelectButtonStyle; - - private AvatarLoaderSettings avatarLoaderSettings; - private AvatarUrlField avatarUrlField; - - private double startTime; - - [Obsolete("Use AvatarLoaderEditor instead")] - public static void ShowWindowMenu() - { - var window = (AvatarLoaderEditorWindow) GetWindow(typeof(AvatarLoaderEditorWindow)); - window.titleContent = new GUIContent(WINDOW_HEADING); - window.ShowUtility(); - AnalyticsEditorLogger.EventLogger.LogOpenDialog(EDITOR_WINDOW_NAME); - } - - private void OnGUI() - { - if (!initialized) Initialize(); - if (avatarUrlField == null) - { - Initialize(); - } - LoadStyles(); - DrawContent(DrawContent, false); - } - - private void OnFocus() - { - avatarUrlField?.ValidateUrl(); - } - - private void DrawContent() - { - Layout.Vertical(() => - { - avatarUrlField.Draw(); - DrawExtras(); - DrawLoadAvatarButton(); - }); - } - - private void LoadStyles() - { - if (avatarButtonStyle == null) - { - avatarButtonStyle = new GUIStyle(GUI.skin.button); - avatarButtonStyle.fontStyle = FontStyle.Bold; - avatarButtonStyle.fontSize = 14; - avatarButtonStyle.margin = new RectOffset(15, 15, 0, 0); - avatarButtonStyle.fixedHeight = ButtonHeight; - } - - if (parametersSelectButtonStyle == null) - { - parametersSelectButtonStyle = new GUIStyle(GUI.skin.button); - parametersSelectButtonStyle.fontStyle = FontStyle.Bold; - parametersSelectButtonStyle.fontSize = 10; - parametersSelectButtonStyle.fixedHeight = 18; - parametersSelectButtonStyle.fixedWidth = 60; - } - - if (errorButtonStyle == null) - { - errorButtonStyle = new GUIStyle(); - errorButtonStyle.fixedWidth = 20; - errorButtonStyle.fixedHeight = 20; - errorButtonStyle.margin = new RectOffset(2, 0, 2, 2); - } - } - - private void Initialize() - { - avatarUrlField = new AvatarUrlField(); - useEyeAnimations = EditorPrefs.GetBool(EYE_ANIMATION_SAVE_KEY); - useVoiceToAnim = EditorPrefs.GetBool(VOICE_TO_ANIM_SAVE_KEY); - - if (EditorPrefs.GetBool(MODEL_CACHING_SAVE_KEY)) EditorPrefs.SetBool(MODEL_CACHING_SAVE_KEY, false); - SetEditorWindowName(EDITOR_WINDOW_NAME, WINDOW_HEADING); - initialized = true; - } - - private void DrawExtras() - { - Layout.Vertical(() => - { - GUILayout.Label("Extras", HeadingStyle); - - Layout.Horizontal(() => - { - GUILayout.Space(15); - - Layout.Vertical(() => - { - useEyeAnimations = EditorGUILayout.ToggleLeft(new GUIContent("Use Eye Animations", - "Optional helper component for random eye rotation and blinking, for a less static look."), useEyeAnimations, - fieldHeight); - EditorPrefs.SetBool(EYE_ANIMATION_SAVE_KEY, useEyeAnimations); - - useVoiceToAnim = EditorGUILayout.ToggleLeft(new GUIContent("Use Voice To Animation", - "Optional helper component for voice amplitude to jaw bone movement."), useVoiceToAnim, fieldHeight); - EditorPrefs.SetBool(VOICE_TO_ANIM_SAVE_KEY, useVoiceToAnim); - }); - }); - GUILayout.Space(2); - }); - } - - - private void DrawLoadAvatarButton() - { - Layout.Horizontal(() => - { - GUI.enabled = avatarUrlField.IsValidUrlShortCode; - if (GUILayout.Button("Load Avatar into the Current Scene", avatarButtonStyle)) - { - startTime = EditorApplication.timeSinceStartup; - AnalyticsEditorLogger.EventLogger.LogLoadAvatarFromDialog(avatarUrlField.Url, useEyeAnimations, useVoiceToAnim); - if (avatarLoaderSettings == null) - { - avatarLoaderSettings = AvatarLoaderSettings.LoadSettings(); - } - var avatarLoader = new AvatarObjectLoader(); - avatarLoader.SaveInProjectFolder = true; - avatarLoader.OnFailed += Failed; - avatarLoader.OnCompleted += Completed; - avatarLoader.OperationCompleted += OnOperationCompleted; - if (avatarLoaderSettings != null) - { - avatarLoader.AvatarConfig = avatarLoaderSettings.AvatarConfig; - if (avatarLoaderSettings.GLTFDeferAgent != null) - { - avatarLoader.GLTFDeferAgent = avatarLoaderSettings.GLTFDeferAgent; - } - } - avatarLoader.LoadAvatar(avatarUrlField.Url); - } - - GUI.enabled = true; - - GUILayout.Space(4); - }); - } - - private void OnOperationCompleted(object sender, IOperation e) - { - if (e.GetType() == typeof(MetadataDownloader)) - { - AnalyticsEditorLogger.EventLogger.LogMetadataDownloaded(EditorApplication.timeSinceStartup - startTime); - } - } - - private void Failed(object sender, FailureEventArgs args) - { - Debug.LogError($"{args.Type} - {args.Message}"); - } - - private void Completed(object sender, CompletionEventArgs args) - { - GameObject avatar = args.Avatar; - - if (useEyeAnimations) avatar.AddComponent(); - if (useVoiceToAnim) avatar.AddComponent(); - var paramHash = AvatarCache.GetAvatarConfigurationHash(avatarLoaderSettings.AvatarConfig); - EditorUtilities.CreatePrefab(avatar, $"{DirectoryUtility.GetRelativeProjectPath(avatar.name, paramHash)}/{avatar.name}.prefab"); - Selection.activeObject = args.Avatar; - AnalyticsEditorLogger.EventLogger.LogAvatarLoaded(EditorApplication.timeSinceStartup - startTime); - } - } -} diff --git a/Editor/UI/Obsolete/AvatarLoaderEditorWindow.cs.meta b/Editor/UI/Obsolete/AvatarLoaderEditorWindow.cs.meta deleted file mode 100644 index 69bd4870..00000000 --- a/Editor/UI/Obsolete/AvatarLoaderEditorWindow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1fc73168af056c04e87056f25328c0d5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/UI/Obsolete/Components.meta b/Editor/UI/Obsolete/Components.meta deleted file mode 100644 index 260b4e71..00000000 --- a/Editor/UI/Obsolete/Components.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b4a6a8e7537e5ff43bb0e214185e4ee3 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/UI/Obsolete/Components/DocumentationButton.cs b/Editor/UI/Obsolete/Components/DocumentationButton.cs deleted file mode 100644 index 8447b6ba..00000000 --- a/Editor/UI/Obsolete/Components/DocumentationButton.cs +++ /dev/null @@ -1,35 +0,0 @@ -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - - - public static class DocumentationButton - { - - private static readonly GUIStyle Style = new GUIStyle(GUI.skin.button) - { - fontSize = 14, - fixedHeight = 18, - fixedWidth = 18, - margin = new RectOffset(2, 2, 0, 8), - padding = new RectOffset(2, 0, 0, 1), - normal = - { - textColor = new Color(0.7f, 0.7f, 0.7f, 1.0f) - }, - alignment = TextAnchor.MiddleCenter - - }; - - public static void Draw(string url) - { - if (GUILayout.Button("?", Style)) - { - Application.OpenURL(url); - } - EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); - } - } -} diff --git a/Editor/UI/Obsolete/Components/DocumentationButton.cs.meta b/Editor/UI/Obsolete/Components/DocumentationButton.cs.meta deleted file mode 100644 index cc463c3a..00000000 --- a/Editor/UI/Obsolete/Components/DocumentationButton.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1f3b436c7c464aba82fcc2bf7f92c1dc -timeCreated: 1683566061 \ No newline at end of file diff --git a/Editor/UI/Obsolete/Components/Footer.cs b/Editor/UI/Obsolete/Components/Footer.cs deleted file mode 100644 index 5583ef41..00000000 --- a/Editor/UI/Obsolete/Components/Footer.cs +++ /dev/null @@ -1,55 +0,0 @@ -using ReadyPlayerMe.Core.Analytics; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - /// - /// Footer for RPM editor windows. Contains buttons for external links. - /// - public class Footer : IEditorWindowComponent - { - private const string DOCS_URL = "https://bit.ly/UnitySDKDocs"; - private const string FAQ_URL = "https://docs.readyplayer.me/overview/frequently-asked-questions/game-engine-faq"; - private const string DISCORD_URL = "https://bit.ly/UnitySDKDiscord"; - - private const float BUTTON_HEIGHT = 30f; - - private readonly GUIStyle webButtonStyle; - - private readonly string editorWindowName; - - public Footer(string editorWindowName) - { - this.editorWindowName = editorWindowName; - webButtonStyle = new GUIStyle(GUI.skin.button); - webButtonStyle.fontSize = 12; - webButtonStyle.fixedWidth = 142; - webButtonStyle.fixedHeight = BUTTON_HEIGHT; - } - - public void Draw(Rect position = new Rect()) - { - Layout.Horizontal(() => - { - GUILayout.Space(15); - if (GUILayout.Button("Documentation", webButtonStyle)) - { - AnalyticsEditorLogger.EventLogger.LogOpenDocumentation(editorWindowName); - Application.OpenURL(DOCS_URL); - } - - if (GUILayout.Button("FAQ", webButtonStyle)) - { - AnalyticsEditorLogger.EventLogger.LogOpenFaq(editorWindowName); - Application.OpenURL(FAQ_URL); - } - - if (GUILayout.Button("Discord", webButtonStyle)) - { - AnalyticsEditorLogger.EventLogger.LogOpenDiscord(editorWindowName); - Application.OpenURL(DISCORD_URL); - } - }); - } - } -} diff --git a/Editor/UI/Obsolete/Components/Footer.cs.meta b/Editor/UI/Obsolete/Components/Footer.cs.meta deleted file mode 100644 index e689775d..00000000 --- a/Editor/UI/Obsolete/Components/Footer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9387c0f7012d00d488db03a7fbc9b735 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/UI/Obsolete/Components/Header.cs b/Editor/UI/Obsolete/Components/Header.cs deleted file mode 100644 index f15ca640..00000000 --- a/Editor/UI/Obsolete/Components/Header.cs +++ /dev/null @@ -1,42 +0,0 @@ -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - public class Header : IEditorWindowComponent - { - private readonly string heading; - private const int WIDTH = 460; - private const int HEIGHT = 100; - private const int FONT_SIZE = 20; - - private readonly Texture2D logo; - private readonly GUIStyle textStyle; - - public Header(string heading) - { - this.heading = heading; - logo = Resources.Load("rpm_logo"); - textStyle = new GUIStyle(); - textStyle.fontSize = FONT_SIZE; - textStyle.richText = true; - textStyle.fontStyle = FontStyle.Bold; - textStyle.normal.textColor = Color.white; - textStyle.alignment = TextAnchor.MiddleLeft; - } - - public void Draw(Rect position) - { - var startPos = new Vector2((position.size.x - WIDTH) / 2, 0); - - var rect = new Rect(startPos.x, startPos.y, WIDTH, HEIGHT); - EditorGUI.DrawRect(rect, Color.black); - - var versionText = new Rect(startPos.x + 15, startPos.y + 35, 40, 40); - EditorGUI.LabelField(versionText, heading, textStyle); - - GUI.DrawTexture(new Rect(startPos.x + WIDTH - 100, startPos.y + 35, 80, 40), logo); - GUILayout.Space(HEIGHT + 20); - } - } -} diff --git a/Editor/UI/Obsolete/Components/Header.cs.meta b/Editor/UI/Obsolete/Components/Header.cs.meta deleted file mode 100644 index 797395a9..00000000 --- a/Editor/UI/Obsolete/Components/Header.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 879e70ffe63d44f28ca5699dbfe04735 -timeCreated: 1683116823 \ No newline at end of file diff --git a/Editor/UI/Obsolete/Components/IEditorWindowComponent.cs b/Editor/UI/Obsolete/Components/IEditorWindowComponent.cs deleted file mode 100644 index 2cdb08c6..00000000 --- a/Editor/UI/Obsolete/Components/IEditorWindowComponent.cs +++ /dev/null @@ -1,6 +0,0 @@ -using UnityEngine; - -public interface IEditorWindowComponent -{ - public void Draw(Rect position); -} diff --git a/Editor/UI/Obsolete/Components/IEditorWindowComponent.cs.meta b/Editor/UI/Obsolete/Components/IEditorWindowComponent.cs.meta deleted file mode 100644 index 79b00870..00000000 --- a/Editor/UI/Obsolete/Components/IEditorWindowComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 35a633cd3376a86429e9dcfbc47b8014 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/UI/Obsolete/Components/SubdomainField.cs b/Editor/UI/Obsolete/Components/SubdomainField.cs deleted file mode 100644 index 62e1aedf..00000000 --- a/Editor/UI/Obsolete/Components/SubdomainField.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System.Linq; -using ReadyPlayerMe.Core.Analytics; -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - public class SubdomainField - { - private const string SUBDOMAIN_FIELD_CONTROL_NAME = "subdomain"; - private const string PARTNERS_DOCS_LINK = "https://docs.readyplayer.me/ready-player-me/for-partners/partner-subdomains"; - private const string QUICKSTART_DOCS_LINK = "https://docs.readyplayer.me/ready-player-me/integration-guides/unity/quickstart#before-you-begin"; - private const string WEB_VIEW_PARTNER_SAVE_KEY = "WebViewPartnerSubdomainName"; - private const string ERROR_ICON_SEARCH_FILTER = "t:Texture rpm_error_icon"; - private const string DOMAIN_VALIDATION_ERROR = "Please enter a valid partner subdomain (e.g. demo). Click here to read more about this issue."; - private const int FONT_SIZE = 12; - private const int ERROR_BUTTON_SIZE = 20; - - private string partnerSubdomain; - private bool subdomainFocused; - private string subdomainAfterFocus = string.Empty; - - public string PartnerSubdomain => partnerSubdomain; - - private GUIStyle textLabelStyle; - private GUIStyle textFieldStyle; - private GUIStyle errorButtonStyle; - - private Texture errorIcon; - - public SubdomainField() - { - partnerSubdomain = CoreSettingsHandler.CoreSettings.Subdomain; - SaveSubdomain(); - LoadAssets(); - } - - public void SetSubdomain(string subdomain) - { - if (partnerSubdomain != subdomain) - { - partnerSubdomain = subdomain; - SaveSubdomain(); - } - } - - public void Draw() - { - LoadStyles(); - - Layout.Horizontal(() => - { - GUILayout.Space(15); - EditorGUILayout.LabelField("Your subdomain:", GUILayout.Width(95)); - DocumentationButton.Draw(Constants.Links.DOCS_PARTNERS_LINK); - EditorGUILayout.LabelField(" https://", textLabelStyle, GUILayout.Width(60)); - var oldValue = partnerSubdomain; - GUI.SetNextControlName(SUBDOMAIN_FIELD_CONTROL_NAME); - partnerSubdomain = EditorGUILayout.TextField(oldValue, textFieldStyle, GUILayout.Width(128), GUILayout.Height(20)); - - EditorGUILayout.LabelField(".readyplayer.me", textLabelStyle, GUILayout.Width(102), GUILayout.Height(20)); - var button = new GUIContent(errorIcon, DOMAIN_VALIDATION_ERROR); - - var isSubdomainValid = IsValidSubdomain(); - - if (!isSubdomainValid) - { - if (GUILayout.Button(button, errorButtonStyle)) - { - Application.OpenURL(PARTNERS_DOCS_LINK); - } - - EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); - } - - if (IsSubdomainFocusLost()) - { - SaveSubdomain(); - } - }); - } - - private void LoadAssets() - { - if (errorIcon == null) - { - var assetGuid = AssetDatabase.FindAssets(ERROR_ICON_SEARCH_FILTER).FirstOrDefault(); - var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid); - - if (assetPath != null) - { - errorIcon = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Texture)) as Texture; - } - } - } - - private void LoadStyles() - { - textFieldStyle ??= new GUIStyle(GUI.skin.textField); - textFieldStyle.fontSize = FONT_SIZE; - - textLabelStyle ??= new GUIStyle(GUI.skin.label); - textLabelStyle.fontStyle = FontStyle.Bold; - textLabelStyle.fontSize = FONT_SIZE; - - errorButtonStyle ??= new GUIStyle(); - errorButtonStyle.fixedWidth = ERROR_BUTTON_SIZE; - errorButtonStyle.fixedHeight = ERROR_BUTTON_SIZE; - errorButtonStyle.margin = new RectOffset(0, 0, 2, 2); - } - - private bool IsValidSubdomain() - { - return !partnerSubdomain.All(char.IsWhiteSpace) && !partnerSubdomain.Contains('/') && !EditorUtilities.IsUrlShortcodeValid(partnerSubdomain); - } - - private bool IsSubdomainFocusLost() - { - // focus changed from subdomain to another item - if (GUI.GetNameOfFocusedControl() == string.Empty && subdomainFocused) - { - subdomainFocused = false; - - if (subdomainAfterFocus != partnerSubdomain) - { - return true; - } - } - if (GUI.GetNameOfFocusedControl() == SUBDOMAIN_FIELD_CONTROL_NAME && !subdomainFocused) - { - subdomainFocused = true; - subdomainAfterFocus = partnerSubdomain; - } - - return false; - } - - public void SaveSubdomain() - { - EditorPrefs.SetString(WEB_VIEW_PARTNER_SAVE_KEY, partnerSubdomain); - var subDomain = CoreSettingsHandler.CoreSettings.Subdomain; - if (subDomain == partnerSubdomain || !IsValidSubdomain()) return; - AnalyticsEditorLogger.EventLogger.LogUpdatePartnerURL(subDomain, partnerSubdomain); - CoreSettingsSetter.SaveSubDomain(partnerSubdomain); - } - } -} diff --git a/Editor/UI/Obsolete/Components/SubdomainField.cs.meta b/Editor/UI/Obsolete/Components/SubdomainField.cs.meta deleted file mode 100644 index 5e3c3024..00000000 --- a/Editor/UI/Obsolete/Components/SubdomainField.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4a1c78c4221c44faaa18558011062dad -timeCreated: 1683195566 \ No newline at end of file diff --git a/Editor/UI/Obsolete/EditorWindowBase.cs b/Editor/UI/Obsolete/EditorWindowBase.cs deleted file mode 100644 index b0026f58..00000000 --- a/Editor/UI/Obsolete/EditorWindowBase.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - /// - /// This EditorWindow class is used as a base class for Ready Player Me Editor windows and contains - /// functionality that is shared between each child class. - /// - public class EditorWindowBase : EditorWindow - { - private const string SUPPORT_HEADING = "Support"; - private const float WIDTH = 460; - private readonly GUILayoutOption windowWidth = GUILayout.Width(WIDTH); - - protected readonly float ButtonHeight = 30f; - - protected GUIStyle HeadingStyle; - - private GUIStyle webButtonStyle; - - private Header header; - private Footer footer; - - private string editorWindowName; - private bool windowResized; - private string heading; - - private void LoadAssets() - { - header ??= new Header(heading); - - footer ??= new Footer(editorWindowName); - - HeadingStyle ??= new GUIStyle - { - fontSize = 14, - richText = true, - fontStyle = FontStyle.Bold, - margin = new RectOffset(15, 0, 0, 8), - normal = - { - textColor = Color.white - } - }; - - webButtonStyle ??= new GUIStyle(GUI.skin.button) - { - fontSize = 12, - fixedWidth = 149, - fixedHeight = ButtonHeight, - padding = new RectOffset(5, 5, 5, 5) - }; - } - - protected void SetEditorWindowName(string editorName, string headingText) - { - heading = headingText; - editorWindowName = editorName; - - } - - protected void DrawContent(Action content, bool useFooter = true) - { - LoadAssets(); - - Layout.Horizontal(() => - { - GUILayout.FlexibleSpace(); - Layout.Vertical(() => - { - header.Draw(position); - content?.Invoke(); - if (useFooter) - { - Layout.Vertical(() => - { - GUILayout.Label(SUPPORT_HEADING, HeadingStyle); - footer.Draw(); - }, true); - } - }, false, windowWidth); - GUILayout.FlexibleSpace(); - }); - - SetWindowSize(); - } - - private void SetWindowSize() - { - var height = GUILayoutUtility.GetLastRect().height; - if (!windowResized && height > 1) - { - minSize = maxSize = new Vector2(WIDTH, height); - windowResized = true; - - } - } - } -} diff --git a/Editor/UI/Obsolete/EditorWindowBase.cs.meta b/Editor/UI/Obsolete/EditorWindowBase.cs.meta deleted file mode 100644 index 8c920551..00000000 --- a/Editor/UI/Obsolete/EditorWindowBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a1ea97792e7bf194c8d5f6351218ffb3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/UI/Obsolete/Helpers.meta b/Editor/UI/Obsolete/Helpers.meta deleted file mode 100644 index 3fd199a0..00000000 --- a/Editor/UI/Obsolete/Helpers.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 98622a00b07646ddb321510275dc0039 -timeCreated: 1683277972 \ No newline at end of file diff --git a/Editor/UI/Obsolete/Helpers/AvatarConfigFields.cs b/Editor/UI/Obsolete/Helpers/AvatarConfigFields.cs deleted file mode 100644 index b83bbf61..00000000 --- a/Editor/UI/Obsolete/Helpers/AvatarConfigFields.cs +++ /dev/null @@ -1,169 +0,0 @@ -using System.IO; -using ReadyPlayerMe.Core.Analytics; -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - public class AvatarConfigFields - { - private const string AVATAR_CONFIG_TOOLTIP = "Assign an avatar configuration to include Avatar API request parameters."; - private const string DEFER_AGENT_TOOLTIP = "Assign a defer agent which decides how the glTF will be loaded."; - private const string CACHING_TOOLTIP = - "Enable caching to improve avatar loading performance at runtime."; - -#if UNITY_EDITOR_LINUX - private const string SHOW_CACHING_FOLDER_BUTTON_TEXT = "Show in file manager"; -#elif UNITY_EDITOR_OSX - private const string SHOW_CACHING_FOLDER_BUTTON_TEXT = "Reveal in finder"; -#else - private const string SHOW_CACHING_FOLDER_BUTTON_TEXT = "Show in explorer"; -#endif - - private const string CLEAR_LOCAL_AVATAR_CACHE = "Clear local avatar cache"; - - private const float BUTTON_HEIGHT = 30f; - private const string AVATAR_CONFIG = "Avatar Config"; - private const string GLTF_DEFER_AGENT = "GLTF defer agent"; - private const string AVATAR_CACHING_TOGGLE_LABEL = "Avatar caching enabled"; - - private readonly GUILayoutOption objectFieldWidth = GUILayout.Width(280); - - private readonly AvatarLoaderSettings avatarLoaderSettings; - public bool IsAvatarConfigFieldEmpty => avatarConfig == null; - - private GUIStyle avatarCachingButtonStyle; - private AvatarConfig avatarConfig; - private GLTFDeferAgent gltfDeferAgent; - - private bool avatarCachingEnabled; - private bool isCacheEmpty; - - public AvatarConfigFields() - { - avatarLoaderSettings = AvatarLoaderSettings.LoadSettings(); - - avatarCachingEnabled = avatarLoaderSettings != null && avatarLoaderSettings.AvatarCachingEnabled; - isCacheEmpty = AvatarCache.IsCacheEmpty(); - if (avatarLoaderSettings != null) - { - avatarConfig = avatarLoaderSettings.AvatarConfig; - gltfDeferAgent = avatarLoaderSettings.GLTFDeferAgent; - } - } - - public void DrawAvatarConfig() - { - Layout.Horizontal(() => - { - GUILayout.Space(15); - EditorGUILayout.LabelField(new GUIContent(AVATAR_CONFIG, AVATAR_CONFIG_TOOLTIP), GUILayout.Width(81)); - DocumentationButton.Draw(Constants.Links.DOCS_AVATAR_CONFIG_LINK); - GUILayout.Space(49); - - avatarConfig = EditorGUILayout.ObjectField(avatarConfig, typeof(AvatarConfig), false, objectFieldWidth) as AvatarConfig; - if (avatarLoaderSettings != null && avatarLoaderSettings.AvatarConfig != avatarConfig) - { - avatarLoaderSettings.AvatarConfig = avatarConfig; - SaveAvatarLoaderSettings(); - } - }); - } - - public void DrawGltfDeferAgent() - { - Layout.Horizontal(() => - { - GUILayout.Space(15); - EditorGUILayout.LabelField(new GUIContent(GLTF_DEFER_AGENT, DEFER_AGENT_TOOLTIP), GUILayout.Width(100)); - DocumentationButton.Draw(Constants.Links.DOCS_DEFER_AGENT_LINK); - GUILayout.Space(30); - - gltfDeferAgent = EditorGUILayout.ObjectField(gltfDeferAgent, typeof(GLTFDeferAgent), false, objectFieldWidth) as GLTFDeferAgent; - if (avatarLoaderSettings != null && avatarLoaderSettings.GLTFDeferAgent != gltfDeferAgent) - { - avatarLoaderSettings.GLTFDeferAgent = gltfDeferAgent; - SaveAvatarLoaderSettings(); - } - }); - } - - public void DrawAvatarCaching() - { - LoadStyles(); - Layout.Horizontal(() => - { - GUILayout.Space(15); - var cachingEnabled = avatarCachingEnabled; - avatarCachingEnabled = EditorGUILayout.ToggleLeft(new GUIContent(AVATAR_CACHING_TOGGLE_LABEL, CACHING_TOOLTIP), avatarCachingEnabled); - - if (cachingEnabled != avatarCachingEnabled && avatarLoaderSettings != null) - { - avatarLoaderSettings.AvatarCachingEnabled = avatarCachingEnabled; - SaveAvatarLoaderSettings(); - } - }); - - GUILayout.Space(4); - - Layout.Horizontal(() => - { - GUILayout.Space(15); - - GUI.enabled = !isCacheEmpty; - if (GUILayout.Button(CLEAR_LOCAL_AVATAR_CACHE, avatarCachingButtonStyle)) - { - TryClearCache(); - isCacheEmpty = AvatarCache.IsCacheEmpty(); - } - GUI.enabled = true; - - if (GUILayout.Button(SHOW_CACHING_FOLDER_BUTTON_TEXT, avatarCachingButtonStyle)) - { - var path = DirectoryUtility.GetAvatarsDirectoryPath(); - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } - EditorUtility.RevealInFinder(path); - } - }); - } - - public void SetIsCacheEmpty() - { - isCacheEmpty = AvatarCache.IsCacheEmpty(); - } - - private void LoadStyles() - { - avatarCachingButtonStyle ??= new GUIStyle(GUI.skin.button); - avatarCachingButtonStyle.fontStyle = FontStyle.Bold; - avatarCachingButtonStyle.fontSize = 12; - avatarCachingButtonStyle.fixedHeight = BUTTON_HEIGHT; - avatarCachingButtonStyle.fixedWidth = 215; - } - - private static void TryClearCache() - { - if (AvatarCache.IsCacheEmpty()) - { - EditorUtility.DisplayDialog("Clear Cache", "Cache is already empty", "OK"); - return; - } - var size = (AvatarCache.GetCacheSize() / (1024f * 1024)).ToString("F2"); - var avatarCount = AvatarCache.GetAvatarCount(); - if (EditorUtility.DisplayDialog("Clear Cache", $"Do you want to clear all the Avatars cache from persistent data path, {size} MB and {avatarCount} avatars?", "Ok", "Cancel")) - { - AvatarCache.Clear(); - } - } - - private void SaveAvatarLoaderSettings() - { - EditorUtility.SetDirty(avatarLoaderSettings); - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - } - } -} diff --git a/Editor/UI/Obsolete/Helpers/AvatarConfigFields.cs.meta b/Editor/UI/Obsolete/Helpers/AvatarConfigFields.cs.meta deleted file mode 100644 index cba41244..00000000 --- a/Editor/UI/Obsolete/Helpers/AvatarConfigFields.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: a28abaa1ebd1438a8e9f95b05611af99 -timeCreated: 1683201510 \ No newline at end of file diff --git a/Editor/UI/Obsolete/Helpers/AvatarUrlField.cs b/Editor/UI/Obsolete/Helpers/AvatarUrlField.cs deleted file mode 100644 index af8ad69e..00000000 --- a/Editor/UI/Obsolete/Helpers/AvatarUrlField.cs +++ /dev/null @@ -1,110 +0,0 @@ -using ReadyPlayerMe.Core.Analytics; -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - public class AvatarUrlField - { - private const string AVATAR_HEADING = "Download Avatar into Scene"; - private const string URL_SHORTCODE_ERROR = "Please enter a valid Avatar URL or Shortcode.Read more."; - private const string ERROR_HELP_URL = "https://docs.readyplayer.me/ready-player-me/avatars/avatar-creator#avatar-url-and-data-format"; - private const string URL_SAVE_KEY = "UrlSaveKey"; - private const int LEFT_MARGIN = 15; - - private readonly GUILayoutOption fieldHeight = GUILayout.Height(20); - private readonly GUILayoutOption fieldWidth = GUILayout.Width(285); - private readonly GUILayoutOption labelWidth = GUILayout.Width(140); - - public bool IsValidUrlShortCode => isValidUrlShortcode; - public string Url => url; - - private bool isValidUrlShortcode; - private GUIStyle headingStyle; - private string url; - - public AvatarUrlField() - { - url = EditorPrefs.GetString(URL_SAVE_KEY); - isValidUrlShortcode = EditorUtilities.IsUrlShortcodeValid(url); - } - - private void LoadStyles() - { - headingStyle ??= new GUIStyle - { - fontSize = 14, - richText = true, - fontStyle = FontStyle.Bold, - margin = new RectOffset(LEFT_MARGIN, 0, 0, 8), - normal = - { - textColor = Color.white - } - }; - } - - - public void Draw() - { - LoadStyles(); - Layout.Vertical(() => - { - Layout.Horizontal(() => - { - GUILayout.Label(AVATAR_HEADING, headingStyle); - DocumentationButton.Draw(Constants.Links.DOCS_LOAD_AVATAR); - GUILayout.FlexibleSpace(); - }); - - Layout.Horizontal(() => - { - GUILayout.Space(LEFT_MARGIN); - - EditorGUILayout.LabelField( - new GUIContent("Avatar URL or Shortcode", "Paste the avatar URL or shortcode received from Ready Player Me here."), labelWidth); - - Layout.Vertical(() => - { - var tempText = EditorUtilities.TextFieldWithPlaceholder(url, " Paste Avatar URL or shortcode here", fieldHeight, fieldWidth); - - if (tempText != url) - { - url = tempText.Split('?')[0]; - isValidUrlShortcode = EditorUtilities.IsUrlShortcodeValid(url); - } - - if (!isValidUrlShortcode) - { - if (GUILayout.Button(URL_SHORTCODE_ERROR, new GUIStyle(GUI.skin.label) - { - richText = true, - fontSize = 10, - fixedHeight = 20, - normal = - { - textColor = new Color(0.7f, 0.7f, 0.7f, 1.0f) - } - }, fieldWidth)) - { - Application.OpenURL(ERROR_HELP_URL); - } - EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); - } - else - { - GUILayout.Space(20); - EditorPrefs.SetString(URL_SAVE_KEY, url); - } - }); - }); - }); - } - - public void ValidateUrl() - { - isValidUrlShortcode = EditorUtilities.IsUrlShortcodeValid(url); - } - - } -} diff --git a/Editor/UI/Obsolete/Helpers/AvatarUrlField.cs.meta b/Editor/UI/Obsolete/Helpers/AvatarUrlField.cs.meta deleted file mode 100644 index 061d9c6f..00000000 --- a/Editor/UI/Obsolete/Helpers/AvatarUrlField.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d32fd3c6081d478dbddf0f2ebf6ddf07 -timeCreated: 1683547454 \ No newline at end of file diff --git a/Editor/UI/Obsolete/Helpers/HeadingAndDescriptionField.cs b/Editor/UI/Obsolete/Helpers/HeadingAndDescriptionField.cs deleted file mode 100644 index 6a5cb2fc..00000000 --- a/Editor/UI/Obsolete/Helpers/HeadingAndDescriptionField.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - public static class HeadingAndDescriptionField - { - private static GUIStyle descriptionStyle; - private static GUIStyle headingStyle; - - private static void LoadStyles() - { - headingStyle ??= new GUIStyle - { - fontSize = 14, - richText = true, - fontStyle = FontStyle.Bold, - margin = new RectOffset(15, 0, 0, 0), - normal = - { - textColor = Color.white - } - }; - - descriptionStyle ??= new GUIStyle(GUI.skin.box) - { - fontSize = 12, - richText = true, - wordWrap = true, - fixedWidth = 435, - margin = new RectOffset(15, 15, 0, 0), - alignment = TextAnchor.UpperLeft, - normal = - { - textColor = new Color(0.7f, 0.7f, 0.7f, 1.0f) - } - }; - } - - public static void SetDescription(string heading, string description, Action extraDescription = null) - { - LoadStyles(); - Layout.Vertical(() => - { - GUILayout.Label(heading, headingStyle); - GUILayout.Space(10); - GUILayout.Label(description, descriptionStyle); - extraDescription?.Invoke(); - }); - } - } -} diff --git a/Editor/UI/Obsolete/Helpers/HeadingAndDescriptionField.cs.meta b/Editor/UI/Obsolete/Helpers/HeadingAndDescriptionField.cs.meta deleted file mode 100644 index 657a1cc0..00000000 --- a/Editor/UI/Obsolete/Helpers/HeadingAndDescriptionField.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 6cb4d248b9a2406abe70b35bd68a8187 -timeCreated: 1683136200 \ No newline at end of file diff --git a/Editor/UI/Obsolete/Layout.cs b/Editor/UI/Obsolete/Layout.cs deleted file mode 100644 index 5867c271..00000000 --- a/Editor/UI/Obsolete/Layout.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - public static class Layout - { - public static void Vertical(Action content, bool isBox = false, params GUILayoutOption[] options) - { - EditorGUILayout.BeginVertical(isBox ? GUI.skin.box : GUIStyle.none, options); - content?.Invoke(); - EditorGUILayout.EndVertical(); - } - - public static void Horizontal(Action content, bool isBox = false, params GUILayoutOption[] options) - { - EditorGUILayout.BeginHorizontal(isBox ? GUI.skin.box : GUIStyle.none, options); - content?.Invoke(); - EditorGUILayout.EndHorizontal(); - } - } -} diff --git a/Editor/UI/Obsolete/Layout.cs.meta b/Editor/UI/Obsolete/Layout.cs.meta deleted file mode 100644 index e532f404..00000000 --- a/Editor/UI/Obsolete/Layout.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f4bdd7cf76b9422f910748d0835c64d3 -timeCreated: 1683112601 \ No newline at end of file diff --git a/Editor/UI/Obsolete/SettingsEditorWindow.cs b/Editor/UI/Obsolete/SettingsEditorWindow.cs deleted file mode 100644 index a3d5e4c5..00000000 --- a/Editor/UI/Obsolete/SettingsEditorWindow.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using ReadyPlayerMe.Core.Analytics; -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - [Obsolete("Use SettingsEditor instead")] - public class SettingsEditorWindow : EditorWindowBase - { - private const string EDITOR_WINDOW_NAME = "rpm settings"; - private const string WINDOW_HEADING = "Settings"; - private const string PARTNER_SETTINGS_HEADING = "Partner Settings"; - private const string HELP_TEXT = - "If you are a Ready Player Me partner, please enter your subdomain here to apply your configuration to the WebView."; - private const string OTHER_SECTION_HEADING = "Other"; - private const string ANALYTICS_LOGGING_DESCRIPTION = - "We are constantly adding new features and improvements to our SDK. Enable analytics and help us in building even better free tools for more developers. This data is used for internal purposes only and is not shared with third parties."; - private const string ANALYTICS_PRIVACY_TOOLTIP = "Click to read our Privacy Policy."; - private const string LOGGING_ENABLED_TOOLTIP = "Enable for detailed console logging of RPM Unity SDK at Runtime and in Editor."; - private const string ANALYTICS_PRIVACY_URL = "https://docs.readyplayer.me/ready-player-me/integration-guides/unity/help-us-improve-the-unity-sdk"; - - private bool initialized; - private bool analyticsEnabled; - private bool sdkLoggingEnabled; - - private GUIStyle saveButtonStyle; - private GUIStyle privacyPolicyStyle; - - private AvatarConfig avatarConfig; - - private SubdomainField subdomainField; - private AvatarConfigFields avatarConfigFields; - - [Obsolete("Use SettingsEditor instead")] - public static void ShowWindowMenu() - { - var window = (SettingsEditorWindow) GetWindow(typeof(SettingsEditorWindow)); - window.titleContent = new GUIContent(WINDOW_HEADING); - window.ShowUtility(); - - AnalyticsEditorLogger.EventLogger.LogOpenDialog(EDITOR_WINDOW_NAME); - } - - private void Initialize() - { - SetEditorWindowName(EDITOR_WINDOW_NAME, WINDOW_HEADING); - - subdomainField = new SubdomainField(); - avatarConfigFields = new AvatarConfigFields(); - - analyticsEnabled = AnalyticsEditorLogger.IsEnabled; - - initialized = true; - sdkLoggingEnabled = SDKLogger.IsLoggingEnabled(); - } - - private void OnFocus() - { - avatarConfigFields?.SetIsCacheEmpty(); - } - - private void OnGUI() - { - if (!initialized) Initialize(); - if (subdomainField == null) - { - Initialize(); - } - - LoadStyles(); - DrawContent(DrawContent); - } - - private void LoadStyles() - { - saveButtonStyle ??= new GUIStyle(GUI.skin.button); - saveButtonStyle.fontSize = 14; - saveButtonStyle.fontStyle = FontStyle.Bold; - saveButtonStyle.fixedWidth = 449; - saveButtonStyle.fixedHeight = ButtonHeight; - saveButtonStyle.padding = new RectOffset(5, 5, 5, 5); - - privacyPolicyStyle ??= new GUIStyle(GUI.skin.label); - privacyPolicyStyle.fontStyle = FontStyle.Bold; - privacyPolicyStyle.fontSize = 12; - privacyPolicyStyle.fixedWidth = 100; - } - - private void DrawContent() - { - Layout.Vertical(() => - { - DrawPartnerSettings(); - DrawAvatarSettings(); - DrawAvatarCaching(); - DrawOtherSection(); - }); - } - - private void DrawPartnerSettings() - { - Layout.Vertical(() => - { - GUILayout.Label(new GUIContent(PARTNER_SETTINGS_HEADING, HELP_TEXT), HeadingStyle); - GUILayout.Space(2); - subdomainField?.Draw(); - }, true); - } - - private void DrawAvatarSettings() - { - Layout.Vertical(() => - { - GUILayout.Label(new GUIContent("Avatar Settings"), HeadingStyle); - - avatarConfigFields?.DrawAvatarConfig(); - EditorGUILayout.Space(3); - avatarConfigFields?.DrawGltfDeferAgent(); - - }, true); - } - - private void DrawAvatarCaching() - { - Layout.Vertical(() => - { - Layout.Horizontal(() => - { - GUILayout.Label("Avatar Caching", HeadingStyle); - DocumentationButton.Draw(Constants.Links.DOCS_AVATAR_CACHING); - GUILayout.FlexibleSpace(); - }); - - avatarConfigFields?.DrawAvatarCaching(); - }, true); - } - - private void DrawOtherSection() - { - Layout.Vertical(() => - { - GUILayout.Label(OTHER_SECTION_HEADING, HeadingStyle); - - Layout.Horizontal(() => - { - GUILayout.Space(15); - analyticsEnabled = EditorGUILayout.ToggleLeft(new GUIContent("Analytics enabled", ANALYTICS_LOGGING_DESCRIPTION), analyticsEnabled, GUILayout.Width(125)); - - if (GUILayout.Button(new GUIContent("(Privacy Policy)", ANALYTICS_PRIVACY_TOOLTIP), privacyPolicyStyle)) - { - Application.OpenURL(ANALYTICS_PRIVACY_URL); - } - - if (AnalyticsEditorLogger.IsEnabled != analyticsEnabled) - { - if (analyticsEnabled) - { - AnalyticsEditorLogger.Enable(); - } - else - { - AnalyticsEditorLogger.Disable(); - } - } - }); - Layout.Horizontal(() => - { - GUILayout.Space(15); - sdkLoggingEnabled = EditorGUILayout.ToggleLeft(new GUIContent("Logging enabled", LOGGING_ENABLED_TOOLTIP), sdkLoggingEnabled, GUILayout.Width(125)); - if (sdkLoggingEnabled != SDKLogger.IsLoggingEnabled()) - { - SDKLogger.EnableLogging(sdkLoggingEnabled); - } - }); - }, true); - } - } -} diff --git a/Editor/UI/Obsolete/SettingsEditorWindow.cs.meta b/Editor/UI/Obsolete/SettingsEditorWindow.cs.meta deleted file mode 100644 index 9eaae3b4..00000000 --- a/Editor/UI/Obsolete/SettingsEditorWindow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 125baf12569bc7a488d4c640aba92d10 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/UI/Obsolete/SetupGuidePanels.meta b/Editor/UI/Obsolete/SetupGuidePanels.meta deleted file mode 100644 index 025eb48d..00000000 --- a/Editor/UI/Obsolete/SetupGuidePanels.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 662144d4b86d44569304fc8df80a0474 -timeCreated: 1683193138 \ No newline at end of file diff --git a/Editor/UI/Obsolete/SetupGuidePanels/AnalyticsPanel.cs b/Editor/UI/Obsolete/SetupGuidePanels/AnalyticsPanel.cs deleted file mode 100644 index e0f18a94..00000000 --- a/Editor/UI/Obsolete/SetupGuidePanels/AnalyticsPanel.cs +++ /dev/null @@ -1,74 +0,0 @@ -using ReadyPlayerMe.Core.Analytics; -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - public class AnalyticsPanel : IEditorWindowComponent - { - private const string HEADING = "Help us improve Ready Player Me SDK"; - private const string DESCRIPTION = - "We are constantly adding new features and improvements to our SDK. Enable analytics and help us in building even better free tools for more developers. This data is used for internal purposes only and is not shared with third parties."; - private const string ANALYTICS_PRIVACY_TEXT = "Read our Privacy Policy and learn how we use the data here"; - private const string ANALYTICS_PRIVACY_URL = - "https://docs.readyplayer.me/ready-player-me/integration-guides/unity/help-us-improve-the-unity-sdk"; - - private const string ENABLE_ANALYTICS_LABEL = "Analytics Enabled"; - - private static bool enableAnalytics; - private static bool previousAnalyticsState; - - private readonly GUILayoutOption toggleWidth = GUILayout.Width(20); - - public AnalyticsPanel() - { - enableAnalytics = AnalyticsEditorLogger.IsEnabled; - } - - public void Draw(Rect position = new Rect()) - { - HeadingAndDescriptionField.SetDescription(HEADING, DESCRIPTION, () => - { - GUILayout.Space(20); - if (GUILayout.Button(ANALYTICS_PRIVACY_TEXT, new GUIStyle(GUI.skin.label) - { - richText = true, - fixedWidth = 435, - margin = new RectOffset(15, 15, 0, 0), - normal = - { - textColor = new Color(0.7f, 0.7f, 0.7f, 1.0f) - } - })) - { - Application.OpenURL(ANALYTICS_PRIVACY_URL); - } - EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); - }); - - GUILayout.FlexibleSpace(); - - Layout.Horizontal(() => - { - GUILayout.Space(15); - enableAnalytics = EditorGUILayout.Toggle(enableAnalytics, toggleWidth); - switch (enableAnalytics) - { - case true when !previousAnalyticsState: - AnalyticsEditorLogger.Enable(); - break; - case false when previousAnalyticsState: - AnalyticsEditorLogger.Disable(); - break; - } - previousAnalyticsState = enableAnalytics; - - GUILayout.Label(ENABLE_ANALYTICS_LABEL); - GUILayout.FlexibleSpace(); - ProjectPrefs.SetBool(ProjectPrefs.FIRST_TIME_SETUP_DONE, enableAnalytics); - }); - - GUILayout.Space(10); - } - } -} diff --git a/Editor/UI/Obsolete/SetupGuidePanels/AnalyticsPanel.cs.meta b/Editor/UI/Obsolete/SetupGuidePanels/AnalyticsPanel.cs.meta deleted file mode 100644 index 8f36fbd6..00000000 --- a/Editor/UI/Obsolete/SetupGuidePanels/AnalyticsPanel.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e5b924e8b1613594da31873c0965d5e3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/UI/Obsolete/SetupGuidePanels/AvatarConfigPanel.cs b/Editor/UI/Obsolete/SetupGuidePanels/AvatarConfigPanel.cs deleted file mode 100644 index 87b4a495..00000000 --- a/Editor/UI/Obsolete/SetupGuidePanels/AvatarConfigPanel.cs +++ /dev/null @@ -1,41 +0,0 @@ -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - public class AvatarConfigPanel : IEditorWindowComponent - { - private const string HEADING = "Avatar Configuration"; - private const string DESCRIPTION = - "To optimize your game or experience, you have multiple options to select the right Quality/Performance settings. You can select between the presets Low (optimum performance), Medium (best tradeoff) and High (optimum visual quality)."; - private const string INFO_TEXT = "You can change this setting later, or fine-tune with your own created Scriptable Object."; - - public bool IsAvatarConfigFieldEmpty => avatarConfigFields.IsAvatarConfigFieldEmpty; - - private readonly AvatarConfigFields avatarConfigFields; - - public AvatarConfigPanel() - { - avatarConfigFields = new AvatarConfigFields(); - } - - public void Draw(Rect position = new Rect()) - { - HeadingAndDescriptionField.SetDescription(HEADING, DESCRIPTION); - - GUILayout.Space(10); - Layout.Horizontal(() => - { - avatarConfigFields.DrawAvatarConfig(); - GUILayout.FlexibleSpace(); - }); - GUILayout.Space(10); - - GUILayout.Label(INFO_TEXT, new GUIStyle(GUI.skin.label) - { - fixedWidth = 435, - wordWrap = true, - margin = new RectOffset(15, 15, 0, 0) - }); - } - } -} diff --git a/Editor/UI/Obsolete/SetupGuidePanels/AvatarConfigPanel.cs.meta b/Editor/UI/Obsolete/SetupGuidePanels/AvatarConfigPanel.cs.meta deleted file mode 100644 index 5bbc6bd4..00000000 --- a/Editor/UI/Obsolete/SetupGuidePanels/AvatarConfigPanel.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4e0d6e461a694592a52c75d6be18dadd -timeCreated: 1683193185 \ No newline at end of file diff --git a/Editor/UI/Obsolete/SetupGuidePanels/SubdomainPanel.cs b/Editor/UI/Obsolete/SetupGuidePanels/SubdomainPanel.cs deleted file mode 100644 index 8cdaeab3..00000000 --- a/Editor/UI/Obsolete/SetupGuidePanels/SubdomainPanel.cs +++ /dev/null @@ -1,75 +0,0 @@ -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - public class SubdomainPanel : IEditorWindowComponent - { - private const string HEADING = "Enter your subdomain"; - private const string DESCRIPTION = - "Please enter your subdomain here. This ensures, that you will get your avatars and the embedded avatar-creator with the configuration you set in Studio (Developer Dashboard)."; - private const string STUDIO_TEXT = "If you don't have a subdomain, you can get one by signing up in Studio.(https://studio.readyplayer.me)"; - private const string STUDIO_URL = - "https://studio.readyplayer.me"; - private const string USE_DEMO_SUBDOMAIN = "I don't have an account. Use demo subdomain instead."; - private const string DEMO_SUBDOMAIN = "demo"; - - private readonly GUILayoutOption toggleWidth = GUILayout.Width(20); - - public bool IsSubdomainFieldEmpty => string.IsNullOrEmpty(subdomainField.PartnerSubdomain); - - private readonly SubdomainField subdomainField; - private bool userDemoSubdomain; - - public SubdomainPanel() - { - subdomainField = new SubdomainField(); - } - - public void Draw(Rect position = new Rect()) - { - HeadingAndDescriptionField.SetDescription(HEADING, DESCRIPTION, () => - { - if (GUILayout.Button(STUDIO_TEXT, new GUIStyle(GUI.skin.label) - { - richText = true, - fixedWidth = 435, - wordWrap = true, - margin = new RectOffset(15, 0, 0, 0), - normal = - { - textColor = new Color(0.7f, 0.7f, 0.7f, 1.0f) - } - })) - { - Application.OpenURL(STUDIO_URL); - } - EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); - }); - GUILayout.Space(20); - - subdomainField.Draw(); - - GUILayout.Space(20); - - Layout.Horizontal(() => - { - GUILayout.Space(15); - userDemoSubdomain = EditorGUILayout.Toggle(userDemoSubdomain, toggleWidth); - if (userDemoSubdomain) - { - subdomainField.SetSubdomain(DEMO_SUBDOMAIN); - } - GUILayout.Label(USE_DEMO_SUBDOMAIN); - GUILayout.FlexibleSpace(); - }); - - GUILayout.Space(10); - } - - public void SaveSubdomain() - { - subdomainField.SaveSubdomain(); - } - } -} diff --git a/Editor/UI/Obsolete/SetupGuidePanels/SubdomainPanel.cs.meta b/Editor/UI/Obsolete/SetupGuidePanels/SubdomainPanel.cs.meta deleted file mode 100644 index 22402353..00000000 --- a/Editor/UI/Obsolete/SetupGuidePanels/SubdomainPanel.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: cf1343b8fd844029a2aa2e364482e0e8 -timeCreated: 1683193162 \ No newline at end of file diff --git a/Editor/UI/Obsolete/SetupGuideWindow.cs b/Editor/UI/Obsolete/SetupGuideWindow.cs deleted file mode 100644 index 8913fe0f..00000000 --- a/Editor/UI/Obsolete/SetupGuideWindow.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System; -using ReadyPlayerMe.Core.Analytics; -using UnityEditor; -using UnityEngine; - -namespace ReadyPlayerMe.Core.Editor -{ - [Obsolete("Use SetupGuide instead")] - public class SetupGuideWindow : EditorWindow - { - private const string WINDOW_NAME = "Setup Guide"; - private const int BUTTON_FONT_SIZE = 12; - - private const string BACK_BUTTON_LABEL = "Back"; - private const string FINISH_SETUP_BUTTON_LABEL = "Finish Setup"; - private const string OPEN_QUICKSTART_SCENE_BUTTON_LABEL = "Open QuickStart Scene"; - - private Header header; - private IEditorWindowComponent[] panels; - private int currentPanelIndex; - - /// - /// Constructor method that subscribes to the StartUp event. - /// - static SetupGuideWindow() - { - if (!ProjectPrefs.GetBool(ProjectPrefs.FIRST_TIME_SETUP_DONE)) - { - EditorApplication.update += OnStartup; - } - } - - /// - /// This method is called when a Unity project is opened or after this Unity package has finished importing and is - /// responsible for displaying the window. It also calls analytics events if enabled. - /// - private static void OnStartup() - { - if (AnalyticsEditorLogger.IsEnabled) - { - EditorApplication.quitting += OnQuit; - } - AnalyticsEditorLogger.Enable(); - ShowWindow(); - - EditorApplication.update -= OnStartup; - } - - /// - /// This method is called when the Unity Editor is closed and logs the close event. - /// - private static void OnQuit() - { - AnalyticsEditorLogger.EventLogger.LogCloseProject(); - } - - [Obsolete("Use SetupGuide instead")] - public static void ShowWindow() - { - GetWindow(typeof(SetupGuideWindow), false, WINDOW_NAME); - ProjectPrefs.SetBool(ProjectPrefs.FIRST_TIME_SETUP_DONE, true); - } - - /// - /// This method the panels and banner if not set already and sets the button event listeners - /// - private void LoadPanels() - { - panels ??= new IEditorWindowComponent[] - { - new SubdomainPanel(), - new AvatarConfigPanel(), - new AnalyticsPanel() - }; - - header ??= new Header(WINDOW_NAME); - } - - private void OnGUI() - { - LoadPanels(); - DrawContent(); - } - - private GUIStyle GetButtonStyle() - { - return new GUIStyle(GUI.skin.button) - { - fontStyle = FontStyle.Bold, - fontSize = BUTTON_FONT_SIZE, - padding = new RectOffset(10, 10, 5, 5), - fixedHeight = 30, - stretchWidth = true - }; - } - - private void DrawContent() - { - minSize = new Vector2(460, 400); - - Layout.Horizontal(() => - { - GUILayout.FlexibleSpace(); - - Layout.Vertical(() => - { - header.Draw(position); - panels[currentPanelIndex].Draw(position); - GUILayout.FlexibleSpace(); - DrawFooter(panels[currentPanelIndex]); - }, false, GUILayout.Height(400)); - }); - } - - private void DrawFooter(IEditorWindowComponent panel) - { - Layout.Horizontal(() => - { - if (!(panel is SubdomainPanel)) - { - GUILayout.Space(15); - if (GUILayout.Button(BACK_BUTTON_LABEL, GetButtonStyle())) - { - OnBackButton(); - } - } - - GUILayout.FlexibleSpace(); - - if (panel is AnalyticsPanel) - { - if (GUILayout.Button(FINISH_SETUP_BUTTON_LABEL, GetButtonStyle())) - { - OnFinishSetup(); - } - - if (GUILayout.Button(OPEN_QUICKSTART_SCENE_BUTTON_LABEL, GetButtonStyle())) - { - OnOpenQuickStartScene(); - } - } - else - { - if (panel is SubdomainPanel { IsSubdomainFieldEmpty: true }) - { - GUI.enabled = false; - } - - if (panel is AvatarConfigPanel { IsAvatarConfigFieldEmpty: true }) - { - GUI.enabled = false; - } - - if (GUILayout.Button("Next", GetButtonStyle())) - { - OnNextButton(); - } - GUI.enabled = true; - } - - GUILayout.Space(15); - - }, true, GUILayout.Width(460)); - } - - private void OnBackButton() - { - currentPanelIndex--; - } - - private void OnNextButton() - { - if (panels[currentPanelIndex] is SubdomainPanel) - { - var subdomainPanel = (SubdomainPanel) panels[currentPanelIndex]; - subdomainPanel.SaveSubdomain(); - } - currentPanelIndex++; - } - - private void OnFinishSetup() - { - Close(); - } - - private void OnOpenQuickStartScene() - { - if (!new QuickStartHelper().Open()) - { - EditorUtility.DisplayDialog(WINDOW_NAME, "No quick start sample found.", "OK"); - } - } - } - -} diff --git a/Editor/UI/Obsolete/SetupGuideWindow.cs.meta b/Editor/UI/Obsolete/SetupGuideWindow.cs.meta deleted file mode 100644 index 00bae61d..00000000 --- a/Editor/UI/Obsolete/SetupGuideWindow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 70817fe9582bddd4dbb1adc761fda887 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/UI/Obsolete/Helpers/QuickStartHelper.cs b/Editor/Utils/QuickStartHelper.cs similarity index 100% rename from Editor/UI/Obsolete/Helpers/QuickStartHelper.cs rename to Editor/Utils/QuickStartHelper.cs diff --git a/Editor/UI/Obsolete/Helpers/QuickStartHelper.cs.meta b/Editor/Utils/QuickStartHelper.cs.meta similarity index 100% rename from Editor/UI/Obsolete/Helpers/QuickStartHelper.cs.meta rename to Editor/Utils/QuickStartHelper.cs.meta From 37d6c86a6a85f48f25335a9cda353bd132bc5005 Mon Sep 17 00:00:00 2001 From: Robin <1121080+rYuuk@users.noreply.github.com> Date: Mon, 30 Oct 2023 14:10:23 +0100 Subject: [PATCH 2/6] feat: generalized sample loading --- Editor/Utils/QuickStartHelper.cs | 56 --------------------------- Editor/Utils/QuickStartHelper.cs.meta | 11 ------ Editor/Utils/SampleLoader.cs | 45 +++++++++++++++++++++ Editor/Utils/SampleLoader.cs.meta | 3 ++ 4 files changed, 48 insertions(+), 67 deletions(-) delete mode 100644 Editor/Utils/QuickStartHelper.cs delete mode 100644 Editor/Utils/QuickStartHelper.cs.meta create mode 100644 Editor/Utils/SampleLoader.cs create mode 100644 Editor/Utils/SampleLoader.cs.meta diff --git a/Editor/Utils/QuickStartHelper.cs b/Editor/Utils/QuickStartHelper.cs deleted file mode 100644 index 8286d74f..00000000 --- a/Editor/Utils/QuickStartHelper.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Linq; -using System.Threading; -using UnityEditor.PackageManager.UI; -using UnityEditor.SceneManagement; - -namespace ReadyPlayerMe.Core.Editor -{ - public class QuickStartHelper - { - private const string LOADER_PACKAGE = "com.readyplayerme.core"; - private const string QUICKSTART_SAMPLE_NAME = "QuickStart"; - - public bool Open() - { - var quickStartSample = GetQuickStartSample(); - if (quickStartSample == null) - { - return false; - } - - var sample = (Sample) quickStartSample; - ImportAndOpenSample(sample); - - return true; - } - - private Sample? GetQuickStartSample() - { - var samples = Sample.FindByPackage(LOADER_PACKAGE, null).ToArray(); - if (samples.Length == 0) - { - return null; - } - - var quickStartSample = samples.First(x => x.displayName == QUICKSTART_SAMPLE_NAME); - return quickStartSample; - } - - private void ImportAndOpenSample(Sample quickStartSample) - { - if (!quickStartSample.isImported) - { - quickStartSample.Import(); - while (!quickStartSample.isImported) - Thread.Sleep(1); - } - - OpenQuickStartScene(quickStartSample.importPath); - } - - private void OpenQuickStartScene(string importPath) - { - EditorSceneManager.OpenScene($"{importPath}/{QUICKSTART_SAMPLE_NAME}.unity"); - } - } -} diff --git a/Editor/Utils/QuickStartHelper.cs.meta b/Editor/Utils/QuickStartHelper.cs.meta deleted file mode 100644 index c54c078a..00000000 --- a/Editor/Utils/QuickStartHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a18cc655bd80acf4db55549f1dd30bd1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Editor/Utils/SampleLoader.cs b/Editor/Utils/SampleLoader.cs new file mode 100644 index 00000000..aef7e638 --- /dev/null +++ b/Editor/Utils/SampleLoader.cs @@ -0,0 +1,45 @@ +using System.Linq; +using System.Threading; +using UnityEditor.PackageManager.UI; +using UnityEditor.SceneManagement; + +namespace ReadyPlayerMe.Core.Editor +{ + public class SampleLoader + { + public bool Load(string packageName, string sampleName) + { + var sample = GetSampleFromPackage(packageName, sampleName); + if (sample == null) + { + return false; + } + + ImportAndOpenSample(sample.Value); + return true; + } + + private Sample? GetSampleFromPackage(string packageName, string sampleName) + { + var samples = Sample.FindByPackage(packageName, null).ToArray(); + if (samples.Length == 0) + { + return null; + } + + return samples.First(x => x.displayName == sampleName); + } + + private void ImportAndOpenSample(Sample quickStartSample) + { + if (!quickStartSample.isImported) + { + quickStartSample.Import(); + while (!quickStartSample.isImported) + Thread.Sleep(1); + } + + EditorSceneManager.OpenScene($"{quickStartSample.importPath}/{quickStartSample.displayName}.unity"); + } + } +} diff --git a/Editor/Utils/SampleLoader.cs.meta b/Editor/Utils/SampleLoader.cs.meta new file mode 100644 index 00000000..d0b4916e --- /dev/null +++ b/Editor/Utils/SampleLoader.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 92e04858783b4fb38d44e160c5910eb4 +timeCreated: 1698670329 \ No newline at end of file From 34f449e6e767446778821619eb8f231429275c9e Mon Sep 17 00:00:00 2001 From: Robin <1121080+rYuuk@users.noreply.github.com> Date: Mon, 30 Oct 2023 14:10:42 +0100 Subject: [PATCH 3/6] feat: add button load avatar creator sample --- Editor/Analytics/AmplitudeEditorLogger.cs | 2 +- Editor/Analytics/IAnalyticsEditorLogger.cs | 1 + .../IntegrationGuide/IntegrationGuide.cs | 52 ++++++++++++++----- .../IntegrationGuide/IntegrationGuide.uxml | 5 +- 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/Editor/Analytics/AmplitudeEditorLogger.cs b/Editor/Analytics/AmplitudeEditorLogger.cs index acf85587..8171591c 100644 --- a/Editor/Analytics/AmplitudeEditorLogger.cs +++ b/Editor/Analytics/AmplitudeEditorLogger.cs @@ -227,7 +227,7 @@ public void LogOpenOptimizationDocumentation() LogEvent(Constants.EventName.OPEN_OPTIMIZATION_DOCUMENTATION); } - public void LogSampleCreatorImported(string packageVersion) + public void LogAvatarCreatorSampleImported() { LogEvent(Constants.EventName.SAMPLE_CREATOR_IMPORTED); } diff --git a/Editor/Analytics/IAnalyticsEditorLogger.cs b/Editor/Analytics/IAnalyticsEditorLogger.cs index 576bcf93..b6ebc252 100644 --- a/Editor/Analytics/IAnalyticsEditorLogger.cs +++ b/Editor/Analytics/IAnalyticsEditorLogger.cs @@ -30,5 +30,6 @@ public interface IAnalyticsEditorLogger void LogOpenAnimationDocumentation(); void LogOpenAvatarCreatorDocumentation(); void LogOpenOptimizationDocumentation(); + void LogAvatarCreatorSampleImported(); } } diff --git a/Editor/UI/EditorWindows/IntegrationGuide/IntegrationGuide.cs b/Editor/UI/EditorWindows/IntegrationGuide/IntegrationGuide.cs index 3cf2f442..3e60b310 100644 --- a/Editor/UI/EditorWindows/IntegrationGuide/IntegrationGuide.cs +++ b/Editor/UI/EditorWindows/IntegrationGuide/IntegrationGuide.cs @@ -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 = "AvatarCreatorSample"; + [SerializeField] private VisualTreeAsset visualTreeAsset; @@ -37,46 +41,66 @@ public void CreateGUI() var headerLabel = rootVisualElement.Q