Skip to content

Commit

Permalink
feat: delete draft avatar, when the new avatar is loaded for update (#…
Browse files Browse the repository at this point in the history
…222)

## [SDK-182](https://ready-player-me.atlassian.net/browse/SDK-182)

## Description

-   Delete the draft avatar, if it exists before editing


## How to Test

- Log into your RPM account  
- Click on the Configure in the avatar in the avatar creator, edit
something, and close the play mode
- play again
- Check, that when customizing the avatar, the previous changes are not
visible.






[SDK-182]:
https://ready-player-me.atlassian.net/browse/SDK-182?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
rk132 authored Feb 9, 2024
2 parents 08b4d69 + 6d73e1d commit ef44e81
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Runtime/AvatarCreator/Scripts/Managers/AvatarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public async Task<string> Save()
/// <summary>
/// This will delete the avatar draft which have not been saved.
/// </summary>
public async void Delete(bool isDraft)
public async Task Delete(bool isDraft)
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class AvatarCreatorSelection : State, IDisposable
[SerializeField] private AvatarConfig inCreatorConfig;
[SerializeField] private RuntimeAnimatorController animator;
[SerializeField] private AccountCreationElement accountCreationElement;

private PartnerAssetsManager partnerAssetManager;
private AvatarManager avatarManager;

Expand Down Expand Up @@ -119,6 +118,11 @@ private void Cleanup()

private void OnErrorCallback(string error)
{
if (error.Equals("Avatar draft not found"))
{
return;
}

SDKLogger.Log(TAG, $"An error occured: {error}");
avatarManager.OnError -= OnErrorCallback;
partnerAssetManager.OnError -= OnErrorCallback;
Expand Down Expand Up @@ -283,9 +287,17 @@ private async void UpdateAvatar(object assetId, AssetType category)
Assets = new Dictionary<AssetType, object>()
};



payload.Assets.Add(category, assetId);
lastRotation = currentAvatar.transform.rotation;
LoadingManager.EnableLoading(UPDATING_YOUR_AVATAR_LOADING_TEXT, LoadingManager.LoadingType.Popup);

if (!AvatarCreatorData.AvatarProperties.isDraft)
{
await avatarManager.Delete(true);
}

var avatar = await avatarManager.UpdateAsset(category, AvatarCreatorData.AvatarProperties.BodyType, assetId);
if (avatar == null)
{
Expand Down

0 comments on commit ef44e81

Please sign in to comment.