From 3dc174c122754e0e2e08ca6b68e5fa39c72cc8fd Mon Sep 17 00:00:00 2001 From: Harrison Date: Thu, 26 Oct 2023 10:26:43 +0300 Subject: [PATCH 1/5] feat: enable empty fields for photo gender prediction --- Runtime/AvatarCreator/WebRequests/AvatarAPIRequests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Runtime/AvatarCreator/WebRequests/AvatarAPIRequests.cs b/Runtime/AvatarCreator/WebRequests/AvatarAPIRequests.cs index 290a894e..0d247eb5 100644 --- a/Runtime/AvatarCreator/WebRequests/AvatarAPIRequests.cs +++ b/Runtime/AvatarCreator/WebRequests/AvatarAPIRequests.cs @@ -138,7 +138,7 @@ public async Task CreateNewAvatar(AvatarProperties avatarPrope { Url = AvatarEndpoints.GetCreateEndpoint(), Method = HttpMethod.POST, - Payload = avatarProperties.ToJson() + Payload = avatarProperties.ToJson(true) }, ctx: ctx ); @@ -154,7 +154,7 @@ public async Task GetAvatar(string avatarId, bool isPreview = false, str var response = await authorizedRequest.SendRequest( new RequestData { - Url =AvatarEndpoints.GetAvatarModelEndpoint(avatarId, isPreview, parameters), + Url = AvatarEndpoints.GetAvatarModelEndpoint(avatarId, isPreview, parameters), Method = HttpMethod.GET }, ctx: ctx); From 05f0566402153ddee4ca523d136ad62b0c611f50 Mon Sep 17 00:00:00 2001 From: Harrison Hough Date: Thu, 26 Oct 2023 16:13:18 +0300 Subject: [PATCH 2/5] chore: test without profileUI --- .../Scripts/ProfileManager.cs | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/Samples~/AvatarCreatorSamples/Scripts/ProfileManager.cs b/Samples~/AvatarCreatorSamples/Scripts/ProfileManager.cs index 040738e5..f3b1724b 100644 --- a/Samples~/AvatarCreatorSamples/Scripts/ProfileManager.cs +++ b/Samples~/AvatarCreatorSamples/Scripts/ProfileManager.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Text; using Newtonsoft.Json; using ReadyPlayerMe.AvatarCreator; @@ -13,7 +14,7 @@ public class ProfileManager : MonoBehaviour private const string DIRECTORY_NAME = "Ready Player Me"; private const string FILE_NAME = "User"; - [SerializeField] private ProfileUI profileUI; + //[SerializeField] private ProfileUI profileUI; private string filePath; private string directoryPath; @@ -26,14 +27,11 @@ private void Awake() private void OnEnable() { - profileUI.SignedOut += AuthManager.Logout; AuthManager.OnSignedOut += DeleteSession; } - private void OnDisable() { - profileUI.SignedOut -= AuthManager.Logout; AuthManager.OnSignedOut -= DeleteSession; } @@ -48,9 +46,10 @@ public bool LoadSession() var json = Encoding.UTF8.GetString(bytes); var userSession = JsonConvert.DeserializeObject(json); AuthManager.SetUser(userSession); - SetProfileData(userSession); - SDKLogger.Log(TAG, $"Loaded session from {filePath}"); + //SetProfileData(userSession); + + SDKLogger.Log(TAG, $"Loaded session from {filePath}"); return true; } @@ -59,27 +58,27 @@ public void SaveSession(UserSession userSession) var json = JsonConvert.SerializeObject(userSession); DirectoryUtility.ValidateDirectory(directoryPath); File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(json)); - SetProfileData(userSession); - + //SetProfileData(userSession); + SDKLogger.Log(TAG, $"Saved session to {filePath}"); } - private void SetProfileData(UserSession userSession) - { - profileUI.SetProfileData( - userSession.Name, - char.ToUpperInvariant(userSession.Name[0]).ToString() - ); - } - + // private void SetProfileData(UserSession userSession) + // { + // profileUI.SetProfileData( + // userSession.Name, + // char.ToUpperInvariant(userSession.Name[0]).ToString() + // ); + // } + private void DeleteSession() { if (File.Exists(filePath)) { File.Delete(filePath); } - profileUI.ClearProfile(); - + //profileUI.ClearProfile(); + SDKLogger.Log(TAG, $"Deleted session at {filePath}"); } } From c9bdfe44afb27efdc9917cd716bdf6c27934f78f Mon Sep 17 00:00:00 2001 From: Harrison Hough Date: Fri, 10 Nov 2023 10:58:29 +0200 Subject: [PATCH 3/5] feat: added props to return type --- Runtime/AvatarCreator/AvatarManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Runtime/AvatarCreator/AvatarManager.cs b/Runtime/AvatarCreator/AvatarManager.cs index 74638da4..8cd82cc8 100644 --- a/Runtime/AvatarCreator/AvatarManager.cs +++ b/Runtime/AvatarCreator/AvatarManager.cs @@ -49,7 +49,7 @@ public AvatarManager(BodyType bodyType, OutfitGender gender, AvatarConfig avatar /// /// Properties which describes avatar /// Avatar gameObject - public async Task CreateAvatar(AvatarProperties avatarProperties) + public async Task<(GameObject, AvatarProperties)> CreateAvatar(AvatarProperties avatarProperties) { GameObject avatar = null; try @@ -57,7 +57,7 @@ public async Task CreateAvatar(AvatarProperties avatarProperties) avatarProperties = await avatarAPIRequests.CreateNewAvatar(avatarProperties); if (ctxSource.IsCancellationRequested) { - return null; + return (null, avatarProperties); } avatarId = avatarProperties.Id; @@ -66,10 +66,10 @@ public async Task CreateAvatar(AvatarProperties avatarProperties) catch (Exception e) { OnError?.Invoke(e.Message); - return avatar; + return (avatar, avatarProperties); } - return avatar; + return (avatar, avatarProperties); } /// From 056a09aaaba5da56af2a7d0fabb4725e6cc869ed Mon Sep 17 00:00:00 2001 From: Harrison Hough Date: Fri, 10 Nov 2023 12:19:04 +0200 Subject: [PATCH 4/5] chore: small refactor --- Runtime/AvatarCreator/AvatarManager.cs | 14 ++++++-------- .../UI/SelectionScreens/AvatarCreatorSelection.cs | 6 ++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Runtime/AvatarCreator/AvatarManager.cs b/Runtime/AvatarCreator/AvatarManager.cs index 8cd82cc8..5aa46d29 100644 --- a/Runtime/AvatarCreator/AvatarManager.cs +++ b/Runtime/AvatarCreator/AvatarManager.cs @@ -14,25 +14,22 @@ public class AvatarManager : IDisposable { private const string TAG = nameof(AvatarManager); private readonly BodyType bodyType; - private readonly OutfitGender gender; private readonly AvatarAPIRequests avatarAPIRequests; private readonly string avatarConfigParameters; private readonly InCreatorAvatarLoader inCreatorAvatarLoader; private readonly CancellationTokenSource ctxSource; - + private OutfitGender gender; public Action OnError { get; set; } public string AvatarId => avatarId; private string avatarId; /// Body type of avatar - /// Gender of avatar /// Config for downloading preview avatar /// Cancellation token - public AvatarManager(BodyType bodyType, OutfitGender gender, AvatarConfig avatarConfig = null, CancellationToken token = default) + public AvatarManager(BodyType bodyType, AvatarConfig avatarConfig = null, CancellationToken token = default) { this.bodyType = bodyType; - this.gender = gender; if (avatarConfig != null) { @@ -55,6 +52,7 @@ public AvatarManager(BodyType bodyType, OutfitGender gender, AvatarConfig avatar try { avatarProperties = await avatarAPIRequests.CreateNewAvatar(avatarProperties); + gender = avatarProperties.Gender; if (ctxSource.IsCancellationRequested) { return (null, avatarProperties); @@ -76,9 +74,8 @@ public AvatarManager(BodyType bodyType, OutfitGender gender, AvatarConfig avatar /// Create a new avatar from a provided template. /// /// Template id - /// Partner name /// Avatar gameObject - public async Task<(GameObject, AvatarProperties)> CreateAvatarFromTemplate(string id, string partner) + public async Task<(GameObject, AvatarProperties)> CreateAvatarFromTemplate(string id) { GameObject avatar = null; var avatarProperties = new AvatarProperties(); @@ -86,9 +83,10 @@ public AvatarManager(BodyType bodyType, OutfitGender gender, AvatarConfig avatar { avatarProperties = await avatarAPIRequests.CreateFromTemplateAvatar( id, - partner, + CoreSettingsHandler.CoreSettings.Subdomain, bodyType ); + gender = avatarProperties.Gender; if (ctxSource.IsCancellationRequested) { return (null, avatarProperties); diff --git a/Samples~/AvatarCreatorSamples/Scripts/UI/SelectionScreens/AvatarCreatorSelection.cs b/Samples~/AvatarCreatorSamples/Scripts/UI/SelectionScreens/AvatarCreatorSelection.cs index 67812156..0392025b 100644 --- a/Samples~/AvatarCreatorSamples/Scripts/UI/SelectionScreens/AvatarCreatorSelection.cs +++ b/Samples~/AvatarCreatorSamples/Scripts/UI/SelectionScreens/AvatarCreatorSelection.cs @@ -65,7 +65,6 @@ private async void Setup() avatarManager = new AvatarManager( AvatarCreatorData.AvatarProperties.BodyType, - AvatarCreatorData.AvatarProperties.Gender, inCreatorConfig, ctxSource.Token); avatarManager.OnError += OnErrorCallback; @@ -158,15 +157,14 @@ private async Task LoadAvatar() if (string.IsNullOrEmpty(AvatarCreatorData.AvatarProperties.Id)) { AvatarCreatorData.AvatarProperties.Assets ??= GetDefaultAssets(); - avatar = await avatarManager.CreateAvatar(AvatarCreatorData.AvatarProperties); + (avatar, _) = await avatarManager.CreateAvatar(AvatarCreatorData.AvatarProperties); } else { if (!AvatarCreatorData.IsExistingAvatar) { (avatar, AvatarCreatorData.AvatarProperties) = await avatarManager.CreateAvatarFromTemplate( - AvatarCreatorData.AvatarProperties.Id, - AvatarCreatorData.AvatarProperties.Partner + AvatarCreatorData.AvatarProperties.Id ); } else From 401906cb55b62f6e9637c10a81b5361dfac7926b Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 13 Nov 2023 13:50:19 +0200 Subject: [PATCH 5/5] chore: undo test comments --- .../Scripts/ProfileManager.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Samples~/AvatarCreatorSamples/Scripts/ProfileManager.cs b/Samples~/AvatarCreatorSamples/Scripts/ProfileManager.cs index f3b1724b..2ba9bacb 100644 --- a/Samples~/AvatarCreatorSamples/Scripts/ProfileManager.cs +++ b/Samples~/AvatarCreatorSamples/Scripts/ProfileManager.cs @@ -14,7 +14,7 @@ public class ProfileManager : MonoBehaviour private const string DIRECTORY_NAME = "Ready Player Me"; private const string FILE_NAME = "User"; - //[SerializeField] private ProfileUI profileUI; + [SerializeField] private ProfileUI profileUI; private string filePath; private string directoryPath; @@ -47,7 +47,7 @@ public bool LoadSession() var userSession = JsonConvert.DeserializeObject(json); AuthManager.SetUser(userSession); - //SetProfileData(userSession); + SetProfileData(userSession); SDKLogger.Log(TAG, $"Loaded session from {filePath}"); return true; @@ -58,18 +58,18 @@ public void SaveSession(UserSession userSession) var json = JsonConvert.SerializeObject(userSession); DirectoryUtility.ValidateDirectory(directoryPath); File.WriteAllBytes(filePath, Encoding.UTF8.GetBytes(json)); - //SetProfileData(userSession); + SetProfileData(userSession); SDKLogger.Log(TAG, $"Saved session to {filePath}"); } - // private void SetProfileData(UserSession userSession) - // { - // profileUI.SetProfileData( - // userSession.Name, - // char.ToUpperInvariant(userSession.Name[0]).ToString() - // ); - // } + private void SetProfileData(UserSession userSession) + { + profileUI.SetProfileData( + userSession.Name, + char.ToUpperInvariant(userSession.Name[0]).ToString() + ); + } private void DeleteSession() { @@ -77,7 +77,7 @@ private void DeleteSession() { File.Delete(filePath); } - //profileUI.ClearProfile(); + profileUI.ClearProfile(); SDKLogger.Log(TAG, $"Deleted session at {filePath}"); }