From e2afffb9c140d9471b142b81f45671bbc98c35db Mon Sep 17 00:00:00 2001 From: Harrison Hough Date: Tue, 2 Jan 2024 15:20:26 +0200 Subject: [PATCH] [SDK-658] Feature/asset store updates (#195) - this PR includes a number of changes to make the SDK more compliant with the unity Asset store requirements - 1 script was edited so that it was wrapped in RPM namespace - removed the Ready Player Me custom file menu, now it is under Tools (as required by asset store) - fixed some issues related to paths like in the Graphics Setting Utility --- .../Module Management/ModuleUpdater.cs | 2 +- .../Settings/GraphicsSettingsUtility.cs | 24 +++--- .../AvatarLoaderEditor/AvatarLoaderEditor.cs | 2 +- .../IntegrationGuide/IntegrationGuide.cs | 2 +- .../SettingsWindow/SettingsEditor.cs | 2 +- .../UI/EditorWindows/SetupGuide/SetupGuide.cs | 2 +- .../Core/Scripts/Utils/AvatarBoneHelper.cs | 77 ++++++++++--------- 7 files changed, 57 insertions(+), 54 deletions(-) diff --git a/Editor/Core/Scripts/Module Management/ModuleUpdater.cs b/Editor/Core/Scripts/Module Management/ModuleUpdater.cs index c07dd967..277ec207 100644 --- a/Editor/Core/Scripts/Module Management/ModuleUpdater.cs +++ b/Editor/Core/Scripts/Module Management/ModuleUpdater.cs @@ -51,7 +51,7 @@ static ModuleUpdater() /// /// Check for Ready Player Me package updates. /// - [MenuItem("Ready Player Me/Check For Updates", priority = 23)] + [MenuItem("Tools/Ready Player Me/Check For Updates", priority = 23)] public static void CheckForUpdates() { AnalyticsEditorLogger.EventLogger.LogCheckForUpdates(); diff --git a/Editor/Core/Scripts/Settings/GraphicsSettingsUtility.cs b/Editor/Core/Scripts/Settings/GraphicsSettingsUtility.cs index c5254d1d..adca4122 100644 --- a/Editor/Core/Scripts/Settings/GraphicsSettingsUtility.cs +++ b/Editor/Core/Scripts/Settings/GraphicsSettingsUtility.cs @@ -1,3 +1,4 @@ +using System.IO; using UnityEditor; using UnityEngine; using UnityEngine.Rendering; @@ -11,11 +12,8 @@ public static class GraphicsSettingsUtility private const string PRELOADED_SHADER_PROPERTY = "m_PreloadedShaders"; private const string GRAPHICS_SETTING_PATH = "ProjectSettings/GraphicsSettings.asset"; -#if RPM_DEVELOPMENT - private const string SHADER_VARIANT_FOLDER = "Assets/Ready Player Me/Core/Runtime/Core/Shaders"; -#else - private const string SHADER_VARIANT_FOLDER = "Packages/com.readyplayerme.core/Runtime/Core/Shaders"; -#endif + private const string SHADER_VARIANT_ASSETS_FOLDER = "Assets/Ready Player Me/Core/Shaders"; + private const string SHADER_VARIANT_PACKAGES_FOLDER = "Packages/com.readyplayerme.core/Shaders"; private const string SHADER_VARIANTS_STANDARD = "glTFastShaderVariants"; private const string SHADER_VARIANTS_URP = "glTFastShaderVariantsURP"; @@ -102,15 +100,17 @@ public static bool IsMissingVariants() private static string GetTargetShaderPath() { - switch (GetCurrentRenderPipeline()) + var shaderFolderPath = SHADER_VARIANT_PACKAGES_FOLDER; + if (!Directory.Exists(shaderFolderPath)) { - case RenderPipeline.URP: - return $"{SHADER_VARIANT_FOLDER}/{SHADER_VARIANTS_URP}{SHADER_VARIANTS_EXTENSION}"; - case RenderPipeline.HDRP: - return $"{SHADER_VARIANT_FOLDER}/{SHADER_VARIANTS_HDRP}{SHADER_VARIANTS_EXTENSION}"; - default: - return $"{SHADER_VARIANT_FOLDER}/{SHADER_VARIANTS_STANDARD}{SHADER_VARIANTS_EXTENSION}"; + shaderFolderPath = SHADER_VARIANT_ASSETS_FOLDER; } + return GetCurrentRenderPipeline() switch + { + RenderPipeline.URP => $"{shaderFolderPath}/{SHADER_VARIANTS_URP}{SHADER_VARIANTS_EXTENSION}", + RenderPipeline.HDRP => $"{shaderFolderPath}/{SHADER_VARIANTS_HDRP}{SHADER_VARIANTS_EXTENSION}", + _ => $"{shaderFolderPath}/{SHADER_VARIANTS_STANDARD}{SHADER_VARIANTS_EXTENSION}" + }; } private static RenderPipeline GetCurrentRenderPipeline() diff --git a/Editor/Core/Scripts/UI/EditorWindows/AvatarLoaderEditor/AvatarLoaderEditor.cs b/Editor/Core/Scripts/UI/EditorWindows/AvatarLoaderEditor/AvatarLoaderEditor.cs index ee54235c..ab39fec0 100644 --- a/Editor/Core/Scripts/UI/EditorWindows/AvatarLoaderEditor/AvatarLoaderEditor.cs +++ b/Editor/Core/Scripts/UI/EditorWindows/AvatarLoaderEditor/AvatarLoaderEditor.cs @@ -26,7 +26,7 @@ public class AvatarLoaderEditor : EditorWindow private bool useEyeAnimations; private bool useVoiceToAnim; - [MenuItem("Ready Player Me/Avatar Loader", priority = 1)] + [MenuItem("Tools/Ready Player Me/Avatar Loader", priority = 1)] public static void ShowWindow() { var window = GetWindow(); diff --git a/Editor/Core/Scripts/UI/EditorWindows/IntegrationGuide/IntegrationGuide.cs b/Editor/Core/Scripts/UI/EditorWindows/IntegrationGuide/IntegrationGuide.cs index 394e2cad..db402a4d 100644 --- a/Editor/Core/Scripts/UI/EditorWindows/IntegrationGuide/IntegrationGuide.cs +++ b/Editor/Core/Scripts/UI/EditorWindows/IntegrationGuide/IntegrationGuide.cs @@ -25,7 +25,7 @@ public class IntegrationGuide : EditorWindow [SerializeField] private VisualTreeAsset visualTreeAsset; - [MenuItem("Ready Player Me/Integration Guide", priority = 12)] + [MenuItem("Tools/Ready Player Me/Integration Guide", priority = 12)] public static void ShowWindow() { var window = GetWindow(); diff --git a/Editor/Core/Scripts/UI/EditorWindows/SettingsWindow/SettingsEditor.cs b/Editor/Core/Scripts/UI/EditorWindows/SettingsWindow/SettingsEditor.cs index 1435c56e..08e00630 100644 --- a/Editor/Core/Scripts/UI/EditorWindows/SettingsWindow/SettingsEditor.cs +++ b/Editor/Core/Scripts/UI/EditorWindows/SettingsWindow/SettingsEditor.cs @@ -47,7 +47,7 @@ public class SettingsEditor : EditorWindow private bool isCacheEmpty; private Button clearCacheButton; - [MenuItem("Ready Player Me/Settings", priority = 1)] + [MenuItem("Tools/Ready Player Me/Settings", priority = 1)] public static void ShowWindow() { var window = GetWindow(); diff --git a/Editor/Core/Scripts/UI/EditorWindows/SetupGuide/SetupGuide.cs b/Editor/Core/Scripts/UI/EditorWindows/SetupGuide/SetupGuide.cs index 787ab91c..eeb712a9 100644 --- a/Editor/Core/Scripts/UI/EditorWindows/SetupGuide/SetupGuide.cs +++ b/Editor/Core/Scripts/UI/EditorWindows/SetupGuide/SetupGuide.cs @@ -34,7 +34,7 @@ public class SetupGuide : EditorWindow private Button finishSetupButton; private Button openQuickStartButton; - [MenuItem("Ready Player Me/Setup Guide", priority = 12)] + [MenuItem("Tools/Ready Player Me/Setup Guide", priority = 12)] public static void ShowWindow() { var window = GetWindow(); diff --git a/Runtime/Core/Scripts/Utils/AvatarBoneHelper.cs b/Runtime/Core/Scripts/Utils/AvatarBoneHelper.cs index 3913afe9..26380676 100644 --- a/Runtime/Core/Scripts/Utils/AvatarBoneHelper.cs +++ b/Runtime/Core/Scripts/Utils/AvatarBoneHelper.cs @@ -1,47 +1,50 @@ using UnityEngine; -/// -/// This static class contains useful helper functions used check and access -/// bones of a loaded avatar. -/// -public static class AvatarBoneHelper +namespace ReadyPlayerMe.Core { - private const string ARMATURE_HIPS_LEFT_UP_LEG_BONE_NAME = "Armature/Hips/LeftUpLeg"; - private const string HALF_BODY_LEFT_EYE_BONE_NAME = "Armature/Hips/Spine/Neck/Head/LeftEye"; - private const string FULL_BODY_LEFT_EYE_BONE_NAME = "Armature/Hips/Spine/Spine1/Spine2/Neck/Head/LeftEye"; - private const string HALF_BODY_RIGHT_EYE_BONE_NAME = "Armature/Hips/Spine/Neck/Head/RightEye"; - private const string FULL_BODY_RIGHT_EYE_BONE_NAME = "Armature/Hips/Spine/Spine1/Spine2/Neck/Head/RightEye"; - /// - /// This is a legacy function that can be used to check if an - /// avatar is fullbody and the object does not have an component + /// This static class contains useful helper functions used check and access + /// bones of a loaded avatar. /// - /// The root transform of the avatar GameObject - /// True if it finds a bone only present in full body avatars - public static bool IsFullBodySkeleton(Transform avatarRoot) + public static class AvatarBoneHelper { - return avatarRoot.Find(ARMATURE_HIPS_LEFT_UP_LEG_BONE_NAME); - } + private const string ARMATURE_HIPS_LEFT_UP_LEG_BONE_NAME = "Armature/Hips/LeftUpLeg"; + private const string HALF_BODY_LEFT_EYE_BONE_NAME = "Armature/Hips/Spine/Neck/Head/LeftEye"; + private const string FULL_BODY_LEFT_EYE_BONE_NAME = "Armature/Hips/Spine/Spine1/Spine2/Neck/Head/LeftEye"; + private const string HALF_BODY_RIGHT_EYE_BONE_NAME = "Armature/Hips/Spine/Neck/Head/RightEye"; + private const string FULL_BODY_RIGHT_EYE_BONE_NAME = "Armature/Hips/Spine/Spine1/Spine2/Neck/Head/RightEye"; - /// - /// Searches the avatar transform hierarchy for the left eye bone - /// - /// The root transform of the avatar GameObject - /// Set to true for fullbody avatar. - /// The transform of the left eye bone or null if not found. - public static Transform GetLeftEyeBone(Transform avatarRoot, bool isFullBody) - { - return avatarRoot.Find(isFullBody ? FULL_BODY_LEFT_EYE_BONE_NAME : HALF_BODY_LEFT_EYE_BONE_NAME); - } + /// + /// This is a legacy function that can be used to check if an + /// avatar is fullbody and the object does not have an component + /// + /// The root transform of the avatar GameObject + /// True if it finds a bone only present in full body avatars + public static bool IsFullBodySkeleton(Transform avatarRoot) + { + return avatarRoot.Find(ARMATURE_HIPS_LEFT_UP_LEG_BONE_NAME); + } - /// - /// Searches the avatar transform hierarchy for the right eye bone - /// - /// The root transform of the avatar GameObject - /// Set to true for fullbody avatar. - /// The transform of the right eye bone or null if not found. - public static Transform GetRightEyeBone(Transform avatarRoot, bool isFullBody) - { - return avatarRoot.Find(isFullBody ? FULL_BODY_RIGHT_EYE_BONE_NAME : HALF_BODY_RIGHT_EYE_BONE_NAME); + /// + /// Searches the avatar transform hierarchy for the left eye bone + /// + /// The root transform of the avatar GameObject + /// Set to true for fullbody avatar. + /// The transform of the left eye bone or null if not found. + public static Transform GetLeftEyeBone(Transform avatarRoot, bool isFullBody) + { + return avatarRoot.Find(isFullBody ? FULL_BODY_LEFT_EYE_BONE_NAME : HALF_BODY_LEFT_EYE_BONE_NAME); + } + + /// + /// Searches the avatar transform hierarchy for the right eye bone + /// + /// The root transform of the avatar GameObject + /// Set to true for fullbody avatar. + /// The transform of the right eye bone or null if not found. + public static Transform GetRightEyeBone(Transform avatarRoot, bool isFullBody) + { + return avatarRoot.Find(isFullBody ? FULL_BODY_RIGHT_EYE_BONE_NAME : HALF_BODY_RIGHT_EYE_BONE_NAME); + } } }