Skip to content

Commit

Permalink
feat: add source param to web avatar creator
Browse files Browse the repository at this point in the history
  • Loading branch information
Raigo Kõvask committed Dec 11, 2023
1 parent 9825f7c commit 9c03c60
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
10 changes: 10 additions & 0 deletions Runtime/WebView/Data/UrlConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.Serialization;

Expand All @@ -13,6 +14,7 @@ public class UrlConfig
private const string TAG = nameof(UrlConfig);
private const string CLEAR_CACHE_PARAM = "clearCache";
private const string FRAME_API_PARAM = "frameApi";
private const string SOURCE_PARAM = "source";
private const string QUICK_START_PARAM = "quickStart";
private const string SELECT_BODY_PARAM = "selectBodyType";
private const string LOGIN_TOKEN_PARAM = "token";
Expand Down Expand Up @@ -41,6 +43,14 @@ public string BuildUrl(string loginToken = "")
var builder = new StringBuilder($"https://{CoreSettingsHandler.CoreSettings.Subdomain}.readyplayer.me/");
builder.Append(language != Language.Default ? $"{language.GetValue()}/" : string.Empty);
builder.Append($"avatar?{FRAME_API_PARAM}");
builder.Append($"&{SOURCE_PARAM}");
#if UNITY_ANDROID
builder.Append($"&{SOURCE_PARAM}=unity-android-avatar-creator");
#elif UNITY_IOS
builder.Append($"&{SOURCE_PARAM}=unity-ios-avatar-creator");
#else
builder.Append($"&{SOURCE_PARAM}=unity-avatar-creator");
#endif
builder.Append(clearCache ? $"&{CLEAR_CACHE_PARAM}" : string.Empty);
if (loginToken != string.Empty)
{
Expand Down
20 changes: 10 additions & 10 deletions Tests/Editor/UrlConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ namespace ReadyPlayerMe.Core.Tests
public class UrlConfigTests : MonoBehaviour
{
private static readonly string URL_BASE = $"https://{CoreSettingsHandler.CoreSettings.Subdomain}.readyplayer.me";
private readonly string URL_DEFAULT = $"{URL_BASE}/avatar?frameApi&selectBodyType";
private readonly string URL_LANG_GERMAN = $"{URL_BASE}/de/avatar?frameApi&selectBodyType";
private readonly string URL_LANG_BRAZIL = $"{URL_BASE}/pt-BR/avatar?frameApi&selectBodyType";
private readonly string URL_DEFAULT = $"{URL_BASE}/avatar?frameApi&source=unity-avatar-creator&selectBodyType";
private readonly string URL_LANG_GERMAN = $"{URL_BASE}/de/avatar?frameApi&source=unity-avatar-creator&selectBodyType";
private readonly string URL_LANG_BRAZIL = $"{URL_BASE}/pt-BR/avatar?frameApi&source=unity-avatar-creator&selectBodyType";

private readonly string URL_GENDER_MALE = $"{URL_BASE}/avatar?frameApi&gender=male&selectBodyType";
private readonly string URL_GENDER_NONE = $"{URL_BASE}/avatar?frameApi&gender=male&selectBodyType";
private readonly string URL_GENDER_MALE = $"{URL_BASE}/avatar?frameApi&source=unity-avatar-creator&gender=male&selectBodyType";
private readonly string URL_GENDER_NONE = $"{URL_BASE}/avatar?frameApi&source=unity-avatar-creator&gender=male&selectBodyType";

private readonly string URL_TYPE_FULLBODY = $"{URL_BASE}/avatar?frameApi&bodyType=fullbody";
private readonly string URL_TYPE_HALFBODY = $"{URL_BASE}/avatar?frameApi&bodyType=halfbody";
private readonly string URL_TYPE_FULLBODY = $"{URL_BASE}/avatar?frameApi&source=unity-avatar-creator&bodyType=fullbody";
private readonly string URL_TYPE_HALFBODY = $"{URL_BASE}/avatar?frameApi&source=unity-avatar-creator&bodyType=halfbody";

private readonly string URL_CLEAR_CACHE = $"{URL_BASE}/avatar?frameApi&clearCache&selectBodyType";
private readonly string URL_CLEAR_CACHE = $"{URL_BASE}/avatar?frameApi&source=unity-avatar-creator&clearCache&selectBodyType";

private readonly string URL_QUICK_START = $"{URL_BASE}/avatar?frameApi&quickStart";
private readonly string URL_TOKEN = $"{URL_BASE}/avatar?frameApi&token=TOKEN&selectBodyType";
private readonly string URL_QUICK_START = $"{URL_BASE}/avatar?frameApi&source=unity-avatar-creator&quickStart";
private readonly string URL_TOKEN = $"{URL_BASE}/avatar?frameApi&source=unity-avatar-creator&token=TOKEN&selectBodyType";
private const string LOGIN_TOKEN = "TOKEN";

public UrlConfig config;
Expand Down

0 comments on commit 9c03c60

Please sign in to comment.