Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: log error, when bodyshapes are not enabled in studio #281

Merged
merged 3 commits into from
May 27, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Runtime/AvatarCreator/Scripts/Managers/AvatarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public AvatarCreationResponse(GameObject avatarObject, AvatarProperties properti
/// </summary>
public class AvatarManager : IDisposable
{
private const string ERROR_BODYSHAPES_NOT_ENABLED = "Failed to apply body shapes to the avatar. Please ensure body shapes are enabled in your studio application.";

private const string TAG = nameof(AvatarManager);
private readonly AvatarAPIRequests avatarAPIRequests;
private readonly string avatarConfigParameters;
Expand Down Expand Up @@ -288,9 +290,36 @@ public async Task<GameObject> UpdateAsset(AssetType assetType, BodyType bodyType
{
return null;
}
await ValidateBodyShapeUpdate(assetType, assetId);


return await inCreatorAvatarLoader.Load(avatarId, bodyType, gender, data);
}

/// <summary>
/// Function that checks if body shapes are enabled in the studio. This validation is performed only in the editor.
/// </summary>
/// <param name="assetType">Assets type that was updated</param>
/// <param name="assetId">Asset ID</param>
private async Task ValidateBodyShapeUpdate(AssetType assetType, object assetId)
{
#if !UNITY_EDITOR
return;
#endif
if (assetType != AssetType.BodyShape)
rk132 marked this conversation as resolved.
Show resolved Hide resolved
{
return;
}

var data = await avatarAPIRequests.GetAvatarMetadata(avatarId, true);
var hasUpdatedAvatarWithAsset = data.Assets.ContainsKey(assetType) && data.Assets[assetType] == assetId;
if (hasUpdatedAvatarWithAsset)
{
return;
}
Debug.LogError(ERROR_BODYSHAPES_NOT_ENABLED);
}


public async Task<Dictionary<AssetType, AssetColor[]>> LoadAvatarColors()
{
Expand Down