Skip to content

Commit

Permalink
[SDK-658] Feature/asset store updates (#195)
Browse files Browse the repository at this point in the history
-   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
  • Loading branch information
HarrisonHough authored Jan 2, 2024
1 parent bf39b05 commit e2afffb
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Editor/Core/Scripts/Module Management/ModuleUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static ModuleUpdater()
/// <summary>
/// Check for Ready Player Me package updates.
/// </summary>
[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();
Expand Down
24 changes: 12 additions & 12 deletions Editor/Core/Scripts/Settings/GraphicsSettingsUtility.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
Expand All @@ -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";
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<AvatarLoaderEditor>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IntegrationGuide>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SettingsEditor>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SetupGuide>();
Expand Down
77 changes: 40 additions & 37 deletions Runtime/Core/Scripts/Utils/AvatarBoneHelper.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,50 @@
using UnityEngine;

/// <summary>
/// This static class contains useful helper functions used check and access
/// bones of a loaded avatar.
/// </summary>
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";

/// <summary>
/// This is a legacy function that can be used to check if an
/// avatar is fullbody and the object does not have an <seealso cref="AvatarData"/> component
/// This static class contains useful helper functions used check and access
/// bones of a loaded avatar.
/// </summary>
/// <param name="avatarRoot">The root transform of the avatar GameObject</param>
/// <returns>True if it finds a bone only present in full body avatars</returns>
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";

/// <summary>
/// Searches the avatar transform hierarchy for the left eye bone
/// </summary>
/// <param name="avatarRoot">The root transform of the avatar GameObject</param>
/// <param name="isFullBody">Set to true for fullbody avatar.</param>
/// <returns>The transform of the left eye bone or null if not found.</returns>
public static Transform GetLeftEyeBone(Transform avatarRoot, bool isFullBody)
{
return avatarRoot.Find(isFullBody ? FULL_BODY_LEFT_EYE_BONE_NAME : HALF_BODY_LEFT_EYE_BONE_NAME);
}
/// <summary>
/// This is a legacy function that can be used to check if an
/// avatar is fullbody and the object does not have an <seealso cref="AvatarData"/> component
/// </summary>
/// <param name="avatarRoot">The root transform of the avatar GameObject</param>
/// <returns>True if it finds a bone only present in full body avatars</returns>
public static bool IsFullBodySkeleton(Transform avatarRoot)
{
return avatarRoot.Find(ARMATURE_HIPS_LEFT_UP_LEG_BONE_NAME);
}

/// <summary>
/// Searches the avatar transform hierarchy for the right eye bone
/// </summary>
/// <param name="avatarRoot">The root transform of the avatar GameObject</param>
/// <param name="isFullBody">Set to true for fullbody avatar.</param>
/// <returns>The transform of the right eye bone or null if not found.</returns>
public static Transform GetRightEyeBone(Transform avatarRoot, bool isFullBody)
{
return avatarRoot.Find(isFullBody ? FULL_BODY_RIGHT_EYE_BONE_NAME : HALF_BODY_RIGHT_EYE_BONE_NAME);
/// <summary>
/// Searches the avatar transform hierarchy for the left eye bone
/// </summary>
/// <param name="avatarRoot">The root transform of the avatar GameObject</param>
/// <param name="isFullBody">Set to true for fullbody avatar.</param>
/// <returns>The transform of the left eye bone or null if not found.</returns>
public static Transform GetLeftEyeBone(Transform avatarRoot, bool isFullBody)
{
return avatarRoot.Find(isFullBody ? FULL_BODY_LEFT_EYE_BONE_NAME : HALF_BODY_LEFT_EYE_BONE_NAME);
}

/// <summary>
/// Searches the avatar transform hierarchy for the right eye bone
/// </summary>
/// <param name="avatarRoot">The root transform of the avatar GameObject</param>
/// <param name="isFullBody">Set to true for fullbody avatar.</param>
/// <returns>The transform of the right eye bone or null if not found.</returns>
public static Transform GetRightEyeBone(Transform avatarRoot, bool isFullBody)
{
return avatarRoot.Find(isFullBody ? FULL_BODY_RIGHT_EYE_BONE_NAME : HALF_BODY_RIGHT_EYE_BONE_NAME);
}
}
}

0 comments on commit e2afffb

Please sign in to comment.