diff --git a/Runtime/Operations/AvatarProcessor.cs b/Runtime/Operations/AvatarProcessor.cs index 114af80e..ff310747 100644 --- a/Runtime/Operations/AvatarProcessor.cs +++ b/Runtime/Operations/AvatarProcessor.cs @@ -47,11 +47,6 @@ public Task Execute(AvatarContext context, CancellationToken toke /// The . private AvatarContext ProcessAvatarGameObject(AvatarContext context) { - GameObject oldInstance = GameObject.Find(context.AvatarUri.Guid); - if (oldInstance) - { - Object.DestroyImmediate(oldInstance); - } ((Object) context.Data).name = context.AvatarUri.Guid; diff --git a/Samples~/AvatarCreatorSamples/Scripts/UI/SelectionScreens/AvatarCreatorSelection.cs b/Samples~/AvatarCreatorSamples/Scripts/UI/SelectionScreens/AvatarCreatorSelection.cs index 18cf2078..67812156 100644 --- a/Samples~/AvatarCreatorSamples/Scripts/UI/SelectionScreens/AvatarCreatorSelection.cs +++ b/Samples~/AvatarCreatorSamples/Scripts/UI/SelectionScreens/AvatarCreatorSelection.cs @@ -291,6 +291,7 @@ private async void UpdateAvatar(object assetId, Category category) } ProcessAvatar(avatar); + Destroy(currentAvatar); currentAvatar = avatar; LoadingManager.DisableLoading(); SDKLogger.Log(TAG, $"Avatar updated in {Time.time - startTime:F2}s"); diff --git a/Tests/Editor/AvatarLoaderTests.cs b/Tests/Editor/AvatarLoaderTests.cs index 99aa99a1..9fd89079 100644 --- a/Tests/Editor/AvatarLoaderTests.cs +++ b/Tests/Editor/AvatarLoaderTests.cs @@ -93,33 +93,6 @@ public IEnumerator AvatarLoader_Fail_Load() Assert.AreNotEqual(FailureType.None, failureType); } - [UnityTest] - public IEnumerator AvatarLoader_Replace_Old_Avatar_Instance() - { - GameObject avatarA = null; - GameObject avatarB = null; - var failureType = FailureType.None; - - var loaderA = new AvatarObjectLoader(); - loaderA.OnCompleted += (_, args) => avatarA = args.Avatar; - loaderA.OnFailed += (_, args) => failureType = args.Type; - loaderA.LoadAvatar(TestAvatarData.DefaultAvatarUri.ModelUrl); - - yield return new WaitUntil(() => avatarA != null || failureType != FailureType.None); - - var loaderB = new AvatarObjectLoader(); - loaderB.OnCompleted += (_, args) => avatarB = args.Avatar; - loaderB.OnFailed += (_, args) => failureType = args.Type; - loaderB.LoadAvatar(TestAvatarData.DefaultAvatarUri.ModelUrl); - - yield return new WaitUntil(() => avatarB != null || failureType != FailureType.None); - - Animator[] objects = Object.FindObjectsOfType(); - - Assert.AreEqual(1, objects.Length); - Assert.AreEqual(FailureType.None, failureType); - } - [UnityTest] public IEnumerator AvatarLoader_Clears_Persistent_Cache() { @@ -179,12 +152,12 @@ public IEnumerator AvatarLoader_Cancel_Loading() public IEnumerator AvatarLoader_Low_LOD_Smaller_than_High_LOD() { var failureType = FailureType.None; - + var avatarConfig = ScriptableObject.CreateInstance(); avatarConfig.Lod = Lod.Low; avatarConfig.TextureAtlas = TextureAtlas.Low; avatarConfig.TextureChannel = Array.Empty(); - + var loader = new AvatarObjectLoader(); loader.OnCompleted += (sender, args) => { @@ -201,7 +174,7 @@ public IEnumerator AvatarLoader_Low_LOD_Smaller_than_High_LOD() loader = new AvatarObjectLoader(); avatarConfig.Lod = Lod.High; loader.AvatarConfig = avatarConfig; - + loader.OnCompleted += (sender, args) => { avatar = args.Avatar;