-
Notifications
You must be signed in to change notification settings - Fork 17
fix: support for RAW GLTF emotes #8377
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7e3ca79
brought back legacy animation support for RAW GLTF emotes
pravusjif f515ae0
applied fix for preview of unreleased RAW GLTF emotes
pravusjif d98a450
fixed preview of unreleased builder emotes + test coverage update
pravusjif c87da8e
Merge branch 'dev' into fix/lsd-scene-emotes
pravusjif a56a7e7
mini refactor for simplifications + test coverage update
pravusjif 361314a
added small test
pravusjif cde8431
covered potential NRE at PlayingEmoteDuration on legacy anims
pravusjif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
.../Assets/DCL/AvatarRendering/AvatarShape/Tests/EditMode/AvatarBaseLegacyAnimationShould.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| using DCL.AvatarRendering.AvatarShape.UnityInterface; | ||
| using NUnit.Framework; | ||
| using UnityEditor; | ||
| using UnityEngine; | ||
| using Utility.Animations; | ||
|
|
||
| namespace DCL.AvatarRendering.AvatarShape.Tests | ||
| { | ||
| public class AvatarBaseLegacyAnimationShould | ||
| { | ||
| private const string AVATAR_BASE_TEST_ASSET_PATH = "Assets/DCL/AvatarRendering/AvatarShape/Tests/Instantiate/TestAssets/AvatarBase_TestAsset.prefab"; | ||
|
|
||
| private GameObject avatarGameObject = null!; | ||
| private AvatarBase avatarBase = null!; | ||
|
|
||
| [SetUp] | ||
| public void SetUp() | ||
| { | ||
| var avatarBasePrefab = AssetDatabase.LoadAssetAtPath<GameObject>(AVATAR_BASE_TEST_ASSET_PATH); | ||
| Assert.IsNotNull(avatarBasePrefab, $"Could not load AvatarBase test prefab from {AVATAR_BASE_TEST_ASSET_PATH}"); | ||
|
|
||
| avatarGameObject = Object.Instantiate(avatarBasePrefab); | ||
| avatarBase = avatarGameObject.GetComponentInChildren<AvatarBase>(); | ||
| Assert.IsNotNull(avatarBase, "AvatarBase component not found on test prefab"); | ||
| Assert.IsNotNull(avatarBase.AvatarAnimator, "AvatarAnimator not configured on test prefab"); | ||
| } | ||
|
|
||
| [TearDown] | ||
| public void TearDown() | ||
| { | ||
| if (avatarGameObject != null) Object.DestroyImmediate(avatarGameObject); | ||
| } | ||
|
|
||
| [Test] | ||
| public void AddOrGetLegacyAnimation_CreatesAnimationOnAvatarAnimatorGameObject() | ||
| { | ||
| Animation legacyAnimation = avatarBase.AddOrGetLegacyAnimation(); | ||
|
|
||
| Assert.IsNotNull(legacyAnimation); | ||
| Assert.AreSame(legacyAnimation, avatarBase.LegacyAnimation); | ||
| Assert.AreSame(avatarBase.AvatarAnimator.gameObject, legacyAnimation.gameObject, | ||
| "PlayLegacyEmote expects the Animation component to live on the same GameObject as the Animator."); | ||
| } | ||
|
|
||
| [Test] | ||
| public void AddOrGetLegacyAnimation_ReturnsSameInstance_OnRepeatedCalls() | ||
| { | ||
| Animation first = avatarBase.AddOrGetLegacyAnimation(); | ||
| Animation second = avatarBase.AddOrGetLegacyAnimation(); | ||
|
|
||
| Assert.AreSame(first, second, | ||
| "Repeated calls must not create duplicate Animation components — AddClip relies on a single stable Animation instance."); | ||
| } | ||
|
|
||
| [Test] | ||
| public void IsLegacyAnimationPlaying_ReturnsFalse_WhenLegacyAnimationExistsButIsNotPlaying() | ||
| { | ||
| avatarBase.AddOrGetLegacyAnimation(); | ||
|
|
||
| Assert.IsFalse(avatarBase.IsLegacyAnimationPlaying, | ||
| "An idle Animation component must not gate the Mecanim animator or its setters."); | ||
| } | ||
|
|
||
| [Test] | ||
| public void StopLegacyAnimation_DoesNotThrow_WhenLegacyAnimationIsIdle() | ||
| { | ||
| avatarBase.AddOrGetLegacyAnimation(); | ||
|
|
||
| Assert.DoesNotThrow(() => avatarBase.StopLegacyAnimation()); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SetAnimatorTrigger_EnablesAnimator_WhenLegacyNotPlaying() | ||
| { | ||
| avatarBase.AvatarAnimator.enabled = false; | ||
|
|
||
| avatarBase.SetAnimatorTrigger(AnimationHashes.EMOTE); | ||
|
|
||
| Assert.IsTrue(avatarBase.AvatarAnimator.enabled, | ||
| "With no legacy animation playing, Mecanim setters must re-enable the Animator to process the new trigger."); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ReplaceEmoteAnimation_EnablesAnimator_WhenLegacyNotPlaying() | ||
| { | ||
| avatarBase.AvatarAnimator.enabled = false; | ||
| var clip = new AnimationClip { legacy = false }; | ||
|
|
||
| avatarBase.ReplaceEmoteAnimation(clip); | ||
|
|
||
| Assert.IsTrue(avatarBase.AvatarAnimator.enabled, | ||
| "ReplaceEmoteAnimation must re-enable the Mecanim animator when no legacy animation is blocking it."); | ||
|
|
||
| Object.DestroyImmediate(clip); | ||
| } | ||
|
|
||
| [Test] | ||
| public void StopLegacyAnimation_StopsAPlayingLegacyClip() | ||
| { | ||
| Animation legacyAnimation = avatarBase.AddOrGetLegacyAnimation(); | ||
| AnimationClip clip = CreateLegacyClip(); | ||
|
|
||
| legacyAnimation.AddClip(clip, clip.name); | ||
| legacyAnimation.Play(clip.name); | ||
|
|
||
| Assume.That(avatarBase.IsLegacyAnimationPlaying, Is.True, | ||
| "Sanity check: legacy clip should report as playing right after Play() in EditMode."); | ||
|
|
||
| avatarBase.StopLegacyAnimation(); | ||
|
|
||
| Assert.IsFalse(avatarBase.IsLegacyAnimationPlaying, | ||
| "StopLegacyAnimation must clear the playing flag so the IsLegacyAnimationPlaying gate releases for the next emote."); | ||
|
|
||
| Object.DestroyImmediate(clip); | ||
| } | ||
|
|
||
| [Test] | ||
| public void SetAnimatorTrigger_Ignored_WhileLegacyAnimationIsPlaying() | ||
| { | ||
| Animation legacyAnimation = avatarBase.AddOrGetLegacyAnimation(); | ||
| AnimationClip clip = CreateLegacyClip(); | ||
| legacyAnimation.AddClip(clip, clip.name); | ||
| legacyAnimation.Play(clip.name); | ||
| Assume.That(avatarBase.IsLegacyAnimationPlaying, Is.True); | ||
|
|
||
| avatarBase.AvatarAnimator.enabled = false; | ||
|
|
||
| avatarBase.SetAnimatorTrigger(AnimationHashes.EMOTE); | ||
|
|
||
| Assert.IsFalse(avatarBase.AvatarAnimator.enabled, | ||
| "While a legacy Animation is playing the Mecanim animator must stay disabled — otherwise motion systems stomp the legacy pose every frame."); | ||
|
|
||
| Object.DestroyImmediate(clip); | ||
| } | ||
|
|
||
| [Test] | ||
| public void ReplaceEmoteAnimation_DoesNotEnableAnimator_WhileLegacyAnimationIsPlaying() | ||
| { | ||
| Animation legacyAnimation = avatarBase.AddOrGetLegacyAnimation(); | ||
| AnimationClip clip = CreateLegacyClip(); | ||
| legacyAnimation.AddClip(clip, clip.name); | ||
| legacyAnimation.Play(clip.name); | ||
| Assume.That(avatarBase.IsLegacyAnimationPlaying, Is.True); | ||
|
|
||
| avatarBase.AvatarAnimator.enabled = false; | ||
| var mecanimClip = new AnimationClip { legacy = false }; | ||
|
|
||
| avatarBase.ReplaceEmoteAnimation(mecanimClip); | ||
|
|
||
| Assert.IsFalse(avatarBase.AvatarAnimator.enabled, | ||
| "Overriding the emote slot while legacy is playing must not re-enable the animator — the switch happens after StopLegacyAnimation releases the gate."); | ||
|
|
||
| Object.DestroyImmediate(clip); | ||
| Object.DestroyImmediate(mecanimClip); | ||
| } | ||
|
|
||
| private static AnimationClip CreateLegacyClip() | ||
| { | ||
| var clip = new AnimationClip { name = "TestLegacyClip", legacy = true }; | ||
| clip.SetCurve(string.Empty, typeof(Transform), "localPosition.x", AnimationCurve.Linear(0, 0, 1, 1)); | ||
| return clip; | ||
| } | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletions
2
...ts/DCL/AvatarRendering/AvatarShape/Tests/EditMode/AvatarBaseLegacyAnimationShould.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.