You've already forked FateViewer
Add project files.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88f6a47f25f3cdf43a488a86696898aa
|
||||
folderAsset: yes
|
||||
timeCreated: 1502400582
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,288 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
|
||||
public class BaseConditionsTests
|
||||
{
|
||||
[UnityTest]
|
||||
public IEnumerator AnimatePhysics_False_DoesntApplyVelocity([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.InstantiateCube(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
var rb = animation.gameObject.AddComponent<Rigidbody>();
|
||||
rb.useGravity = false;
|
||||
animation.gameObject.GetComponent<BoxCollider>().enabled = false;
|
||||
animation.animatePhysics = false;
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.Play("test");
|
||||
|
||||
yield return null;
|
||||
yield return null;
|
||||
Assert.AreEqual(0f, rb.velocity.x);
|
||||
Assert.AreEqual(0f, rb.velocity.z);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator CullingMode_AlwaysAnimate_Animates_InvisibleObject([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.InstantiateCube(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.cullingMode = AnimatorCullingMode.AlwaysAnimate;
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.gameObject.GetComponent<MeshRenderer>().enabled = false;
|
||||
animation.Play("test");
|
||||
|
||||
yield return null;
|
||||
yield return null;
|
||||
Assert.AreNotEqual(Vector3.zero, animation.gameObject.transform.localPosition);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator CullingMode_CullCompletely_Doesnt_Animate_InvisibleObject([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.InstantiateCube(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.cullingMode = AnimatorCullingMode.CullCompletely;
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.gameObject.GetComponent<MeshRenderer>().enabled = false;
|
||||
animation.Play("test");
|
||||
|
||||
yield return null;
|
||||
yield return null;
|
||||
Assert.AreEqual(Vector3.zero, animation.gameObject.transform.localPosition);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsPlaying_BeforePlay_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
Assert.AreEqual(false, animation.isPlaying);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsPlaying_AfterPlay_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.Play("test");
|
||||
Assert.AreEqual(true, animation.isPlaying);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator IsPlaying_AfterStop_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.Play("test");
|
||||
yield return null;
|
||||
animation.Stop();
|
||||
Assert.AreEqual(false, animation.isPlaying);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator IsPlaying_AfterClipDone_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
clipInstance.wrapMode = WrapMode.Once;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.Play("test");
|
||||
yield return new WaitForSeconds(2f);
|
||||
Assert.AreEqual(false, animation.isPlaying);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator IsPlaying_AfterCrossfadeDone_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
clipInstance.wrapMode = WrapMode.Once;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.AddClip(clipInstance, "test2");
|
||||
animation.Play("test");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
animation.CrossFade("test2", 1.5f);
|
||||
yield return new WaitForSeconds(2.0f);
|
||||
Assert.AreEqual(false, animation.isPlaying);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DefaultClip_DoesntPlay_When_IsPlayingAutomatically_IsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
animation.clip = clipInstance;
|
||||
animation.playAutomatically = false;
|
||||
|
||||
Assert.AreEqual(false, animation.isPlaying);
|
||||
Assert.AreEqual(false, animation.IsPlaying(animation.clip.name));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DefaultClip_Plays_When_IsPlayingAutomatically_IsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
animation.clip = clipInstance;
|
||||
animation.playAutomatically = true;
|
||||
|
||||
var newGO = Object.Instantiate<GameObject>(animation.gameObject);
|
||||
animation = newGO.GetComponent<IAnimation>();
|
||||
|
||||
Assert.AreEqual(true, animation.isPlaying);
|
||||
var defaultName = animation.usesLegacy ? animation.clip.name : "Default";
|
||||
Assert.AreEqual(true, animation.IsPlaying(defaultName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PlayAutomatically_HasNoEffect_WhenThereIsNo_DefaultClip([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
animation.playAutomatically = true;
|
||||
|
||||
var newGO = Object.Instantiate<GameObject>(animation.gameObject);
|
||||
animation = newGO.GetComponent<IAnimation>();
|
||||
|
||||
Assert.AreEqual(false, animation.isPlaying);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PlayAutomatically_WithNo_DefaultClip_HasNoEffect_OnOtherClips([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
animation.playAutomatically = true;
|
||||
animation.AddClip(clipInstance, clipInstance.name);
|
||||
|
||||
var newGO = Object.Instantiate<GameObject>(animation.gameObject);
|
||||
animation = newGO.GetComponent<IAnimation>();
|
||||
|
||||
Assert.AreEqual(false, animation.isPlaying);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PlayAutomatically_With_DefaultClip_HasNoEffect_OnOtherClips([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
animation.clip = clipInstance;
|
||||
animation.playAutomatically = true;
|
||||
animation.AddClip(clipInstance, "OtherClip");
|
||||
|
||||
Assert.AreEqual(false, animation.IsPlaying("OtherClip"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PlayAutomatically_BeforeSet_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
Assert.AreEqual(true, animation.playAutomatically);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PlayAutomatically_AfterSet_True_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
animation.playAutomatically = true;
|
||||
Assert.AreEqual(true, animation.playAutomatically);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PlayAutomatically_AfterSet_False_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
animation.playAutomatically = false;
|
||||
Assert.AreEqual(false, animation.playAutomatically);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator WrapMode_Default_UsesClipSetting([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
clipInstance.wrapMode = WrapMode.Loop;
|
||||
|
||||
animation.wrapMode = WrapMode.Default;
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.Play("test");
|
||||
|
||||
yield return new WaitForSeconds(1.2f);
|
||||
Assert.AreEqual(true, animation.isPlaying);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator WrapMode_OverridesClipsWithDefaultSetting([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
clipInstance.wrapMode = WrapMode.Default;
|
||||
|
||||
animation.wrapMode = WrapMode.Loop;
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.Play("test");
|
||||
|
||||
yield return new WaitForSeconds(1.2f);
|
||||
Assert.AreEqual(true, animation.isPlaying);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator WrapMode_DoesntOverrideClipsSetting([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
clipInstance.wrapMode = WrapMode.Once;
|
||||
|
||||
animation.wrapMode = WrapMode.Loop;
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.Play("test");
|
||||
|
||||
yield return new WaitForSeconds(1.2f);
|
||||
Assert.AreEqual(false, animation.isPlaying);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94d35051e65be294187c9630c79078d1
|
||||
timeCreated: 1494560140
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,202 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class ClipManagementTests
|
||||
{
|
||||
public class GetClipCount
|
||||
{
|
||||
[Test]
|
||||
public void GetClipCount_BeforeAdd_ReturnsZero([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
Assert.AreEqual(0, animation.GetClipCount(), "Component should have no clips connected at this point");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetClipCount_AfterAddOne_ReturnsOne([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
animation.AddClip(clipInstance, "test");
|
||||
|
||||
Assert.AreEqual(1, animation.GetClipCount(), "Component should have 1 clip connected after add");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetClipCount_AfterRemoveSingleClip_ReturnsZero([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.RemoveClip("test");
|
||||
|
||||
Assert.AreEqual(0, animation.GetClipCount(), "Component should have no clips after remove");
|
||||
}
|
||||
}
|
||||
|
||||
public class AddClip
|
||||
{
|
||||
[Test]
|
||||
public void AddClip_WithNullClip_Throws_NullReferenceException([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
Assert.Throws<System.NullReferenceException> (() => { animation.AddClip(null, "test"); });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddClip_TwiceWithSameName_GetClipCount_ReturnsOne([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
LogAssert.ignoreFailingMessages = true; //The error message here is irrelevant
|
||||
animation.AddClip(clipInstance, "test");
|
||||
LogAssert.ignoreFailingMessages = false;
|
||||
|
||||
Assert.AreEqual(1, animation.GetClipCount(), "Component should have no clips after remove");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddClip_TwiceDifferentName_GetClipCount_ReturnsTwo([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.AddClip(clipInstance, "test2");
|
||||
Assert.AreEqual(2, animation.GetClipCount(), "Component should have no clips after remove");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddClip_WithSameName_AsClip_DoenstCreateNewClip([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, clipInstance.name);
|
||||
IAnimationState state = animation.GetState(clipInstance.name);
|
||||
Assert.AreEqual(clipInstance, state.clip, "Component should have no clips after remove");
|
||||
}
|
||||
}
|
||||
|
||||
public class RemoveClip_ByAnimationClip
|
||||
{
|
||||
[Test]
|
||||
public void RemoveClip_AnimationClip_WithNullClip_Throws_NullReferenceException([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
AnimationClip clip = null;
|
||||
Assert.Throws<System.NullReferenceException> (() => { animation.RemoveClip(clip); });
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Description("AddClip always duplicates clips in the Animation Component, making it very hard to remove clips")]
|
||||
public void RemoveClip_AnimationClip_RemovesClip([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, clipInstance.name);
|
||||
animation.RemoveClip(clipInstance);
|
||||
Assert.AreEqual(0, animation.GetClipCount(), "Component should have no clips after remove");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveClip_AnimationClip_DoesntRemoveUnrelatedClips([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clip2 = Resources.Load<AnimationClip>("LinearY");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
var clipInstance2 = Object.Instantiate<AnimationClip>(clip2);
|
||||
clipInstance2.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, clipInstance.name);
|
||||
animation.AddClip(clipInstance2, clipInstance2.name);
|
||||
animation.RemoveClip(clipInstance);
|
||||
Assert.AreEqual(1, animation.GetClipCount(), "Component should still have 1 connected clip after remove");
|
||||
Assert.NotNull(animation.GetState(clipInstance2.name));
|
||||
}
|
||||
}
|
||||
|
||||
public class RemoveClip_ByName
|
||||
{
|
||||
[Test]
|
||||
public void RemoveClip_ByName_WithEmptyName_Works([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "");
|
||||
animation.RemoveClip("");
|
||||
Assert.AreEqual(0, animation.GetClipCount(), "Component should still have 1 connected clip after remove");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveClip_ByName_DoesntRemoveOtherClips([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
var legacyClip2 = Object.Instantiate<AnimationClip>(clipInstance);
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.AddClip(legacyClip2, "test2");
|
||||
animation.RemoveClip("test");
|
||||
Assert.AreEqual(1, animation.GetClipCount(), "Component should still have 1 connected clip after remove");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveClip_ByName_RemovesClip([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.RemoveClip("test");
|
||||
Assert.AreEqual(0, animation.GetClipCount(), "Component should still have 1 connected clip after remove");
|
||||
}
|
||||
}
|
||||
|
||||
public class RemoveClip
|
||||
{
|
||||
[Test]
|
||||
public void RemoveClip_Invalidates_ExistingState([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, clipInstance.name);
|
||||
IAnimationState state = animation.GetState(clipInstance.name);
|
||||
animation.RemoveClip(clipInstance);
|
||||
Assert.IsFalse(state.isValid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b00cae6d5f62bb41a1a48f5c48069fe
|
||||
timeCreated: 1494560140
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
class ComparativeTestFixture
|
||||
{
|
||||
private static System.Type[] Sources()
|
||||
{
|
||||
return new Type [] { typeof(AnimationProxy), typeof(SimpleAnimationProxy) };
|
||||
}
|
||||
|
||||
public static IAnimation Instantiate(System.Type type)
|
||||
{
|
||||
var go = new GameObject();
|
||||
var component = go.AddComponent(type);
|
||||
return component as IAnimation;
|
||||
}
|
||||
|
||||
public static IAnimation InstantiateCube(System.Type type)
|
||||
{
|
||||
var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
var component = go.AddComponent(type);
|
||||
return component as IAnimation;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98de67babe968c640aa589d5b3a449c2
|
||||
timeCreated: 1496940236
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,189 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class DifferencesTests
|
||||
{
|
||||
[Test]
|
||||
[Ignore("The Animation Component creates a new internal clip instance when a state has a different name than the name of the clip. This was deemed an undesirable behavior")]
|
||||
public void AddClip_WithNewName_CreatesNewClip([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "NewName");
|
||||
IAnimationState state = animation.GetState("NewName");
|
||||
Assert.AreNotEqual(clipInstance, state.clip, "AddClip should have created a new clip instance");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("This is where the new component differs. Animation won't let you remove multiple states with the same clip, because it's not possible to have the same clip twice")]
|
||||
public void RemoveClip_AnimationClip_RemovesAllInstances([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.AddClip(clipInstance, "test2");
|
||||
animation.RemoveClip(clipInstance);
|
||||
Assert.AreEqual(0, animation.GetClipCount(), "Component should have no clips after remove");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
[Ignore("Time does not advance on the frame on which Rewind is called on SimpleAnimation")]
|
||||
public IEnumerator Rewind_PlaysFrameZero([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
animation.AddClip(clipInstanceX, "ValidName");
|
||||
animation.Play("ValidName");
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
Assert.AreNotEqual(0f, animation.gameObject.transform.localPosition.x);
|
||||
animation.Rewind("ValidName");
|
||||
yield return null;
|
||||
Assert.AreEqual(0f, animation.gameObject.transform.localPosition.x);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Check were added to SimpleAnimation to prevent using invalid names")]
|
||||
public void Rewind_WithInvalidName_FailsOnCall([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
LogAssert.Expect(LogType.Error, new Regex(""));
|
||||
animation.Rewind("InvalidName");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("Check were added to SimpleAnimation to prevent using invalid names")]
|
||||
public void Stop_WithInvalidName_FailsOnCall([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
LogAssert.Expect(LogType.Error, new Regex(""));
|
||||
animation.Stop("InvalidName");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("The Animation Component accepts null as a valid name")]
|
||||
public void State_Name_NullString_Throws_ArgumentNullException([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
Assert.Throws<System.ArgumentNullException>(() => { state.name = null; });
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
[Ignore("Setting time guarantees you that the next automatic evaluation will use the time you supplied with Playables, whereas Animation Component will update the frame time")]
|
||||
public IEnumerator State_Time_SetTime_PreventsUpdatingTimeAutomatically([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
float time = Time.time;
|
||||
state.time = 0.1f; //empty run for the Animation component, probably a side effect of reenabling the component
|
||||
yield return null;
|
||||
|
||||
state.time = 0.1f;
|
||||
yield return null;
|
||||
|
||||
Assert.AreEqual(0.1f, state.time);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
[Ignore("The Animation Component doesn't advance on the first frame")]
|
||||
public IEnumerator State_Time_IsSynchronizedWith_GameTime([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
float previousTime = Time.time;
|
||||
yield return null;
|
||||
yield return null;
|
||||
yield return null;
|
||||
float elapsedTime = Time.time - previousTime;
|
||||
Assert.AreEqual(elapsedTime, state.time, 0.001f, "State time should be equal to elapsed time");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
[Ignore("In the Animation Component, RemoveClip doesn't remove queued instances of the removed clip, whereas Stop stops both the queued instances and the playing instances. This inconsistency was deemed undesirable")]
|
||||
public IEnumerator Queue_RemoveClip_StopsQueuedClips([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "PlayAndQueue");
|
||||
animation.Play("PlayAndQueue");
|
||||
animation.PlayQueued("PlayAndQueue", QueueMode.CompleteOthers);
|
||||
yield return null;
|
||||
animation.RemoveClip("PlayAndQueue");
|
||||
Assert.IsFalse(animation.isPlaying);
|
||||
yield return null;
|
||||
Assert.IsFalse(animation.isPlaying);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
[Ignore("States that play backwards should still be Queue-compatible, which is not the case in the Animation Component")]
|
||||
public IEnumerator NegativeSpeed_Does_Trigger_Crossfade([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "PlayBackwards");
|
||||
animation.AddClip(clipInstance, "Crossfade");
|
||||
IAnimationState state = animation.GetState("PlayBackwards");
|
||||
state.enabled = true;
|
||||
state.time = 0.5f;
|
||||
state.speed = -1f;
|
||||
animation.PlayQueued("Crossfade", QueueMode.CompleteOthers);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
Assert.IsTrue(state.enabled);
|
||||
Assert.IsTrue(animation.IsPlaying("Crossfade"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
[Ignore("The Animation Component doesn't apply velocities to rigidbodies with AnimatePhysics on")]
|
||||
public IEnumerator AnimatePhysics_True_AppliesVelocity([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.InstantiateCube(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
var rb = animation.gameObject.AddComponent<Rigidbody>();
|
||||
rb.useGravity = false;
|
||||
animation.animatePhysics = true;
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.Play("test");
|
||||
|
||||
yield return null;
|
||||
yield return new WaitForSeconds(0.3f);
|
||||
Assert.AreNotEqual(rb.velocity, Vector3.zero);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b19f00406c66144ab1f66fe9c78fabb
|
||||
timeCreated: 1499370755
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class MiscTests
|
||||
{
|
||||
[UnityTest]
|
||||
public IEnumerator StateSpeed_Affects_WhenCrossfadeHappens([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "PlaySlowly");
|
||||
animation.AddClip(clipInstance, "Queued");
|
||||
IAnimationState state = animation.GetState("PlaySlowly");
|
||||
state.enabled = true;
|
||||
state.speed = 0.1f;
|
||||
animation.PlayQueued("Queued", QueueMode.CompleteOthers);
|
||||
|
||||
//Wait for the original length of PlaySlowly
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
Assert.IsFalse(animation.IsPlaying("Queued"), "Clip 'Queued' should not be playing yet. Speed is probably applied wrong.");
|
||||
state.speed = 1000.0f;
|
||||
yield return null;
|
||||
yield return null;
|
||||
Assert.IsTrue(animation.IsPlaying("Queued"), "Clip 'PlaySlowly' should now be done, and clip 'Queued' should have started playing.");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator PlayQueue_WithLoopedAnimation_Prevents_StateAccess_OfOriginalState_FromWorking_Correctly([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
var loopedClipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
loopedClipInstance.legacy = animation.usesLegacy;
|
||||
loopedClipInstance.wrapMode = WrapMode.Loop;
|
||||
|
||||
animation.AddClip(clipInstance, "FirstClip");
|
||||
animation.AddClip(loopedClipInstance, "LoopedClip");
|
||||
animation.Play("FirstClip");
|
||||
animation.PlayQueued("LoopedClip", QueueMode.CompleteOthers);
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
Assert.IsTrue(animation.IsPlaying("LoopedClip"), "Clip 'LoopedClip' should be playing");
|
||||
IAnimationState state = animation.GetState("LoopedClip");
|
||||
|
||||
Assert.IsFalse(state.enabled, "We should be playing a copy of LoopedClip, not the LoopedClip State");
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
state = animation.GetState("LoopedClip");
|
||||
Assert.IsFalse(state.enabled, "We should still be playing a copy of LoopedClip, not the LoopedClip State");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6e209b2d0c68024ebd0ce0df3d50480
|
||||
timeCreated: 1499452822
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,806 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class PlaybackTests
|
||||
{
|
||||
public class Play
|
||||
{
|
||||
[Test]
|
||||
public void Play_WithInvalidName_FailsOnCall([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
LogAssert.Expect(LogType.Error, new Regex(""));
|
||||
animation.Play("WrongState");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Play_ValidName_IsPlaying_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "RightName");
|
||||
animation.Play("RightName");
|
||||
Assert.IsTrue(animation.isPlaying, "The clip RightName should be playing");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Play_ValidName_MovesObject([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
animation.Play("ValidName");
|
||||
|
||||
//TODO: replace by Seek(time)
|
||||
yield return null;
|
||||
yield return null;
|
||||
yield return null;
|
||||
|
||||
Assert.AreNotEqual(0f, animation.gameObject.transform.localPosition.x, "LocalPosition.x should have been moved by the clip");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Play_OtherClip_IsPlaying_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
var clipInstance2 = Object.Instantiate<AnimationClip>(clipInstance);
|
||||
clipInstance2.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ClipToPlayOver");
|
||||
animation.AddClip(clipInstance2, "ClipThatPlaysOver");
|
||||
animation.Play("ClipToPlayOver");
|
||||
yield return null;
|
||||
animation.Play("ClipThatPlaysOver");
|
||||
|
||||
Assert.IsFalse(animation.IsPlaying("ClipToPlayOver"), "ClipToPlayOver should be stopped by playing ClipThatPlaysOver");
|
||||
Assert.IsTrue(animation.IsPlaying("ClipThatPlaysOver"), "ClipThatPlaysOver should now be the only playing clip");
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Play_SameClip_StateTime_DoesntChange([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.Play("test");
|
||||
|
||||
yield return null;
|
||||
|
||||
float time = animation.GetState("test").time;
|
||||
animation.Play("test");
|
||||
Assert.AreEqual(time, animation.GetState("test").time);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Play_SameClip_Done_StateTime_Resets([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "test");
|
||||
animation.Play("test");
|
||||
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
|
||||
float time = animation.GetState("test").time;
|
||||
animation.Play("test");
|
||||
Assert.AreEqual(0f, animation.GetState("test").time);
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayQueue_CompleteOthers
|
||||
{
|
||||
[Test]
|
||||
public void PlayQueue_WithInvalidName_FailsOnCall([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
LogAssert.Expect(LogType.Error, new Regex(""));
|
||||
animation.PlayQueued("InvalidName", QueueMode.CompleteOthers);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator PlayQueue_WithNoClipPlaying_IsStatePlaying_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlayQueue");
|
||||
animation.PlayQueued("ToPlayQueue", QueueMode.CompleteOthers);
|
||||
|
||||
yield return null;
|
||||
Assert.IsTrue(animation.IsPlaying("ToPlayQueue"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator PlayQueue_WithClipPlaying_IsStatePlaying_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlay");
|
||||
animation.AddClip(clipInstance, "ToPlayQueue");
|
||||
animation.Play("ToPlay");
|
||||
animation.PlayQueued("ToPlayQueue", QueueMode.CompleteOthers);
|
||||
|
||||
Assert.IsFalse(animation.IsPlaying("ToPlayQueue"));
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator PlayQueue_WithClipPlaying_IsStatePlaying_AfterOriginalClipDone_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlay");
|
||||
animation.AddClip(clipInstance, "ToPlayQueue");
|
||||
animation.Play("ToPlay");
|
||||
animation.PlayQueued("ToPlayQueue", QueueMode.CompleteOthers);
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
|
||||
Assert.IsTrue(animation.IsPlaying("ToPlayQueue"));
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator PlayQueue_Queueing_SameClip_AfterFirstClipIsDone_IsPlaying_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlayAndPlayQueue");
|
||||
animation.Play("ToPlayAndPlayQueue");
|
||||
animation.PlayQueued("ToPlayAndPlayQueue", QueueMode.CompleteOthers);
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
|
||||
Assert.IsTrue(animation.IsPlaying("ToPlayAndPlayQueue"));
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayQueue_PlayNow
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class Crossfade
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void Crossfade_WithInvalidName_FailsOnCall([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
LogAssert.Expect(LogType.Error, new Regex(""));
|
||||
animation.CrossFade("InvalidName", 0);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Crossfade_WithValidName_IsPlaying_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToCrossfade");
|
||||
animation.CrossFade("ToCrossfade", 0f);
|
||||
|
||||
Assert.IsTrue(animation.IsPlaying("ToCrossfade"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Crossfade_WithValidName_MovesObject([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToCrossfade");
|
||||
animation.CrossFade("ToCrossfade", 0f);
|
||||
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
Assert.AreNotEqual(0f, animation.gameObject.transform.localPosition.x);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Crossfade_LengthZero_StopsOtherClips([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlay");
|
||||
animation.AddClip(clipInstance, "ToCrossfade");
|
||||
animation.CrossFade("ToPlay", 0f);
|
||||
animation.CrossFade("ToCrossfade", 0.0f);
|
||||
|
||||
Assert.IsFalse(animation.IsPlaying("ToPlay"));
|
||||
}
|
||||
[Test]
|
||||
public void Crossfade_DoesntStopOtherClips([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlay");
|
||||
animation.AddClip(clipInstance, "ToCrossfade");
|
||||
animation.CrossFade("ToPlay", 0f);
|
||||
animation.CrossFade("ToCrossfade", 0.2f);
|
||||
|
||||
Assert.IsTrue(animation.IsPlaying("ToPlay"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator CrossfadedOut_Clips_AreStopped([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlay");
|
||||
animation.AddClip(clipInstance, "ToCrossfade");
|
||||
animation.Play("ToPlay");
|
||||
animation.CrossFade("ToCrossfade", 0.1f);
|
||||
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
Assert.IsFalse(animation.IsPlaying("ToPlay"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator CrossfadedOut_Clips_AreTimeReset([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlay");
|
||||
animation.AddClip(clipInstance, "ToCrossfade");
|
||||
animation.Play("ToPlay");
|
||||
animation.CrossFade("ToCrossfade", 0.1f);
|
||||
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
Assert.AreEqual(0.0f, animation.GetState("ToPlay").normalizedTime);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Crossfade_MultipleTimes_DoesntReset_Crossfade_Duration([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clip2 = Resources.Load<AnimationClip>("LinearY");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
var clipInstance2 = Object.Instantiate<AnimationClip>(clip2);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
clipInstance2.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlay");
|
||||
animation.AddClip(clipInstance2, "ToCrossfade");
|
||||
animation.Play("ToPlay");
|
||||
animation.CrossFade("ToCrossfade", 0.2f);
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
animation.CrossFade("ToCrossfade", 0.2f);
|
||||
yield return new WaitForSeconds(0.11f);
|
||||
Assert.AreEqual(0.0f, animation.GetState("ToPlay").weight);
|
||||
Assert.AreEqual(1.0f, animation.GetState("ToCrossfade").weight);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
[Ignore("Wrong Assumption; clips don't get kept alive by crossfade")]
|
||||
public IEnumerator Crossfade_FromFinishingClip_KeepsClipAlive_UntilCrossfadeDone([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipY = Resources.Load<AnimationClip>("LinearY");
|
||||
var xClip = Object.Instantiate<AnimationClip>(clipX);
|
||||
var yClip = Object.Instantiate<AnimationClip>(clipY);
|
||||
xClip.legacy = animation.usesLegacy;
|
||||
yClip.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(xClip, "ToPlay");
|
||||
animation.AddClip(yClip, "ToCrossfade");
|
||||
animation.Play("ToPlay");
|
||||
|
||||
yield return new WaitForSeconds(0.9f);
|
||||
|
||||
Assert.IsTrue(animation.IsPlaying("ToPlay"));
|
||||
Assert.AreNotEqual(0f, animation.gameObject.transform.localPosition.y);
|
||||
animation.CrossFade("ToCrossfade", 0.5f);
|
||||
yield return new WaitForSeconds(0.3f);
|
||||
|
||||
Assert.AreNotEqual(0f, animation.gameObject.transform.localPosition.y);
|
||||
Assert.IsTrue(animation.IsPlaying("ToCrossfade"));
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
[Ignore("Wrong Assumption; clips don't get kept alive by crossfade")]
|
||||
public IEnumerator Crossfade_LongerThanClip_KeepsClipAlive_UntilCrossfadeDone([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipY = Resources.Load<AnimationClip>("LinearY");
|
||||
var xClip = Object.Instantiate<AnimationClip>(clipX);
|
||||
var yClip = Object.Instantiate<AnimationClip>(clipY);
|
||||
xClip.legacy = animation.usesLegacy;
|
||||
yClip.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(yClip, "ToPlay");
|
||||
animation.AddClip(xClip, "ToCrossfade");
|
||||
animation.Play("ToPlay");
|
||||
|
||||
yield return new WaitForSeconds(0.9f);
|
||||
|
||||
Assert.IsTrue(animation.IsPlaying("ToPlay"));
|
||||
Assert.AreNotEqual(0f, animation.gameObject.transform.localPosition.y);
|
||||
animation.CrossFade("ToCrossfade", 1.2f);
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
|
||||
Assert.AreNotEqual(0f, animation.gameObject.transform.localPosition.y);
|
||||
Assert.IsTrue(animation.IsPlaying("ToCrossfade"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class CrossfadeQueue
|
||||
{
|
||||
[Test]
|
||||
public void CrossfadeQueue_WithNoClipAttached_FailsOnCall([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
LogAssert.Expect(LogType.Error, new Regex(""));
|
||||
animation.CrossFadeQueued("UnknownState", 0f, QueueMode.CompleteOthers);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator CrossfadeQueue_WithInvalidName_FailsOnCall([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlay");
|
||||
LogAssert.Expect(LogType.Error, new Regex(""));
|
||||
animation.CrossFadeQueued("invalidName", 0f, QueueMode.CompleteOthers);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator CrossfadeQueue_WithNoClipPlaying_IsStatePlaying_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToPlay");
|
||||
animation.CrossFadeQueued("ToPlay", 0f, QueueMode.CompleteOthers);
|
||||
|
||||
yield return null;
|
||||
Assert.IsTrue(animation.IsPlaying("ToPlay"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator CrossfadeQueue_WithClipPlaying_IsStatePlaying_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipY = Resources.Load<AnimationClip>("LinearY");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
var clipInstanceY = Object.Instantiate<AnimationClip>(clipY);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
clipInstanceY.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstanceY, "ToPlay");
|
||||
animation.AddClip(clipInstanceX, "ToCrossfade");
|
||||
animation.Play("ToPlay");
|
||||
animation.CrossFadeQueued("ToCrossfade", 0.5f, QueueMode.CompleteOthers);
|
||||
yield return null;
|
||||
|
||||
Assert.IsFalse(animation.IsPlaying("ToCrossfade"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator CrossfadeQueue_WithClipPlaying_IsStatePlaying_AfterOriginalClipDone_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipY = Resources.Load<AnimationClip>("LinearY");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
var clipInstanceY = Object.Instantiate<AnimationClip>(clipY);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
clipInstanceY.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstanceY, "ToPlay");
|
||||
animation.AddClip(clipInstanceX, "ToCrossfade");
|
||||
animation.Play("ToPlay");
|
||||
animation.CrossFadeQueued("ToCrossfade", 0.0f, QueueMode.CompleteOthers);
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
|
||||
Assert.IsTrue(animation.IsPlaying("ToCrossfade"));
|
||||
}
|
||||
}
|
||||
|
||||
public class Stop
|
||||
{
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Stop_ValidName_NotPlaying_IsPlaying_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
animation.AddClip(clipInstanceX, "ValidName");
|
||||
|
||||
yield return null;
|
||||
|
||||
animation.Stop("ValidName");
|
||||
Assert.IsFalse(animation.IsPlaying("ValidName"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Stop_ValidName_Playing_IsPlaying_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
animation.AddClip(clipInstanceX, "ValidName");
|
||||
animation.Play("ValidName");
|
||||
|
||||
yield return null;
|
||||
|
||||
animation.Stop("ValidName");
|
||||
Assert.IsFalse(animation.IsPlaying("ValidName"));
|
||||
}
|
||||
[UnityTest]
|
||||
public IEnumerator Stop_ValidName_DoesntMoveObject([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
animation.AddClip(clipInstanceX, "ValidName");
|
||||
animation.Play("ValidName");
|
||||
|
||||
yield return null;
|
||||
|
||||
Vector3 localPos = animation.gameObject.transform.localPosition;
|
||||
animation.Stop("ValidName");
|
||||
Assert.AreEqual(localPos, animation.gameObject.transform.localPosition);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Stop_WithName_OtherClip_IsPlaying_DoesntChange([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipY = Resources.Load<AnimationClip>("LinearY");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
var clipInstanceY = Object.Instantiate<AnimationClip>(clipY);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
clipInstanceY.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstanceY, "ClipToStop");
|
||||
animation.AddClip(clipInstanceX, "OtherClip");
|
||||
var stateToStop = animation.GetState("ClipToStop");
|
||||
var otherState = animation.GetState("OtherClip");
|
||||
|
||||
stateToStop.weight = 1f;
|
||||
stateToStop.enabled = true;
|
||||
otherState.weight = 1f;
|
||||
otherState.enabled = true;
|
||||
|
||||
yield return null;
|
||||
|
||||
animation.Stop("ClipToStop");
|
||||
Assert.IsFalse(animation.IsPlaying("ClipToStop"));
|
||||
Assert.IsTrue(animation.IsPlaying("OtherClip"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Stop_WithoutName_IsPlaying_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipY = Resources.Load<AnimationClip>("LinearY");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
var clipInstanceY = Object.Instantiate<AnimationClip>(clipY);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
clipInstanceY.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstanceY, "clip1");
|
||||
animation.AddClip(clipInstanceX, "clip2");
|
||||
|
||||
animation.GetState("clip1").enabled = true;
|
||||
animation.GetState("clip1").weight = 0.5f;
|
||||
|
||||
animation.GetState("clip2").enabled = true;
|
||||
animation.GetState("clip2").weight = 0.5f;
|
||||
|
||||
Assert.IsTrue(animation.IsPlaying("clip1"));
|
||||
Assert.IsTrue(animation.IsPlaying("clip2"));
|
||||
yield return null;
|
||||
|
||||
animation.Stop();
|
||||
Assert.IsFalse(animation.IsPlaying("clip1"));
|
||||
Assert.IsFalse(animation.IsPlaying("clip2"));
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Stop_Playing_StoppedState_DoesntFire_AnyEvents([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var eventReceiver = animation.gameObject.AddComponent<SimpleAnimationTests.ReceivesEvent>();
|
||||
var clip = Resources.Load<AnimationClip>("FiresEvent");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "FiresEvent");
|
||||
animation.Play("FiresEvent");
|
||||
yield return new WaitForSeconds(0.6f);
|
||||
|
||||
Assert.AreEqual(1, eventReceiver.eventCount, "Event at 0.5 should have fired");
|
||||
animation.Stop("FiresEvent");
|
||||
animation.Play("FiresEvent");
|
||||
Assert.AreEqual(0.0f, animation.GetState("FiresEvent").time, "Time should have reset to 0");
|
||||
Assert.AreEqual(1, eventReceiver.eventCount, "No new event should have fired");
|
||||
yield return null;
|
||||
Assert.AreEqual(1, eventReceiver.eventCount, "No new event should have fired after update");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class Rewind
|
||||
{
|
||||
[Test]
|
||||
public void Rewind_ValidName_NotPlaying_StateTime_IsZero([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
animation.AddClip(clipInstanceX, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.time = 0.5f;
|
||||
animation.Rewind("ValidName");
|
||||
Assert.AreEqual(0f, state.time);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Rewind_ValidName_Playing_StateTime_IsZero([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
animation.AddClip(clipInstanceX, "ValidName");
|
||||
animation.Play("ValidName");
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
animation.Rewind("ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
Assert.AreEqual(0f, state.time);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Rewind_WithName_OtherClip_Time_DoesntChange([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToRewind");
|
||||
animation.AddClip(clipInstance, "ToLeaveAlone");
|
||||
IAnimationState toRewind = animation.GetState("ToRewind");
|
||||
toRewind.time = 0.5f;
|
||||
IAnimationState toLeaveAlone = animation.GetState("ToLeaveAlone");
|
||||
toLeaveAlone.time = 0.5f;
|
||||
|
||||
animation.Rewind("ToRewind");
|
||||
Assert.AreNotEqual(0f, toLeaveAlone.time);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Rewind_WithoutName_AllStateTimes_AreZero([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ToRewind");
|
||||
animation.AddClip(clipInstance, "ToRewindToo");
|
||||
IAnimationState toRewind = animation.GetState("ToRewind");
|
||||
toRewind.time = 0.5f;
|
||||
IAnimationState toRewindToo = animation.GetState("ToRewindToo");
|
||||
toRewindToo.time = 0.5f;
|
||||
|
||||
animation.Rewind();
|
||||
Assert.AreEqual(0f, toRewind.time);
|
||||
Assert.AreEqual(0f, toRewindToo.time);
|
||||
}
|
||||
}
|
||||
|
||||
public class Sample
|
||||
{
|
||||
[Test]
|
||||
public void Sample_DoesntChange_StateTime([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstanceX, "clip1");
|
||||
|
||||
animation.GetState("clip1").enabled = true;
|
||||
animation.GetState("clip1").weight = 1f;
|
||||
animation.GetState("clip1").time = 0.5f;
|
||||
animation.Sample();
|
||||
|
||||
Assert.AreEqual(0.5f, animation.gameObject.transform.localPosition.x);
|
||||
Assert.IsTrue(Mathf.Approximately(0.5f, animation.GetState("clip1").time));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Sample_EvaluatesAt_StateTime([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstanceX, "ToSample");
|
||||
IAnimationState state = animation.GetState("ToSample");
|
||||
|
||||
state.enabled = true;
|
||||
state.weight = 1f;
|
||||
state.time = 0.5f;
|
||||
animation.Sample();
|
||||
|
||||
Assert.AreEqual(0.5f, animation.gameObject.transform.localPosition.x);
|
||||
}
|
||||
}
|
||||
|
||||
public class Blend
|
||||
{
|
||||
[Test]
|
||||
public void Blend_AfterBlend_Instant_State_IsPlaying([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstanceX, "ToBlend");
|
||||
animation.Blend("ToBlend", 1, 0);
|
||||
|
||||
Assert.IsTrue(animation.IsPlaying("ToBlend"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Blend_AfterBlend_NonInstant_State_IsPlaying([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstanceX, "ToBlend");
|
||||
animation.Blend("ToBlend", 1, 0.5f);
|
||||
|
||||
Assert.IsTrue(animation.IsPlaying("ToBlend"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Blend_DoesntChange_OtherState_Weight([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance1 = Object.Instantiate<AnimationClip>(clipX);
|
||||
var clipInstance2 = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstance1.legacy = animation.usesLegacy;
|
||||
clipInstance2.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance1, "ToBlend");
|
||||
animation.AddClip(clipInstance2, "ToLeaveAlone");
|
||||
animation.Play("ToLeaveAlone");
|
||||
animation.Blend("ToBlend", 1f, 0f);
|
||||
|
||||
Assert.AreEqual(1f, animation.GetState("ToLeaveAlone").weight);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Blend_Instant_WithWeightZero_State_DoesntStop_State([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstanceX, "ToBlend");
|
||||
animation.Blend("ToBlend", 0, 0);
|
||||
yield return null;
|
||||
Assert.IsTrue(animation.IsPlaying("ToBlend"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PlayQueued
|
||||
{
|
||||
[UnityTest]
|
||||
public IEnumerator PlayQueued_Only_Plays_QueuedAnimations_Once([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clipX = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstanceX = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceX.legacy = animation.usesLegacy;
|
||||
var clipInstanceXOnce = Object.Instantiate<AnimationClip>(clipX);
|
||||
clipInstanceXOnce.legacy = animation.usesLegacy;
|
||||
clipInstanceXOnce.wrapMode = WrapMode.Once;
|
||||
|
||||
animation.AddClip(clipInstanceX, "A");
|
||||
animation.AddClip(clipInstanceX, "B");
|
||||
animation.AddClip(clipInstanceX, "C");
|
||||
|
||||
animation.Play("A");
|
||||
animation.PlayQueued("B", QueueMode.CompleteOthers);
|
||||
animation.PlayQueued("C", QueueMode.CompleteOthers);
|
||||
yield return new WaitForSeconds(2.8f);
|
||||
Assert.IsTrue(animation.IsPlaying("C"));
|
||||
yield return new WaitForSeconds(0.3f);
|
||||
Assert.IsFalse(animation.isPlaying);
|
||||
}
|
||||
//TODO: Crossfade and Play clears queued animations
|
||||
//TODO: Stop clears queued animations
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fd08db4a0ee3ce47b1e4f8a0913f89d
|
||||
timeCreated: 1494560140
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class QueueTests
|
||||
{
|
||||
[UnityTest]
|
||||
public IEnumerator Queue_Stop_Clip_StopsQueuedClip([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "PlayAndQueue");
|
||||
animation.Play("PlayAndQueue");
|
||||
animation.PlayQueued("PlayAndQueue", QueueMode.CompleteOthers);
|
||||
yield return null;
|
||||
animation.Stop("PlayAndQueue");
|
||||
Assert.IsFalse(animation.isPlaying);
|
||||
yield return null;
|
||||
//Queued animation would have started if it was going to.
|
||||
Assert.IsFalse(animation.isPlaying);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Enabled_DoesntCover_QueuedState([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "PlayAndQueue");
|
||||
animation.Play("PlayAndQueue");
|
||||
animation.PlayQueued("PlayAndQueue", QueueMode.CompleteOthers);
|
||||
IAnimationState state = animation.GetState("PlayAndQueue");
|
||||
Assert.IsTrue(state.enabled);
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
Assert.IsFalse(state.enabled);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator Queue_Looped_Clips_Block_QueuedAnimations([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
clipInstance.wrapMode = WrapMode.Loop;
|
||||
|
||||
animation.AddClip(clipInstance, "Play");
|
||||
animation.AddClip(clipInstance, "Queued");
|
||||
animation.Play("Play");
|
||||
animation.PlayQueued("Queued", QueueMode.CompleteOthers);
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
Assert.IsFalse(animation.IsPlaying("Queued"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92ce3265af6ad694c9d214d1b4fd6adc
|
||||
timeCreated: 1499439871
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,693 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
|
||||
public class StateAccessTests
|
||||
{
|
||||
public class BaseTests
|
||||
{
|
||||
[Test]
|
||||
public void GetState_WithNoState_ReturnsNull([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
|
||||
IAnimationState state = animation.GetState("InvalidName");
|
||||
Assert.AreEqual(null, state);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetState_WithState_ReturnsState([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
Assert.AreNotEqual(null, state);
|
||||
Assert.AreEqual("ValidName", state.name);
|
||||
}
|
||||
}
|
||||
|
||||
public class TimeTests
|
||||
{
|
||||
[Test]
|
||||
public void State_Time_Equals_Zero_BeforePlay([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
Assert.AreEqual(0f, state.time);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Time_Equals_Zero_AfterPlay([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
Assert.AreEqual(0f, state.time);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Time_Affects_ClipPlayback([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.enabled = true;
|
||||
state.weight = 1f;
|
||||
state.time = 0.5f;
|
||||
animation.Sample();
|
||||
Assert.AreEqual(animation.gameObject.transform.localPosition.x, state.time, "Sampling should have updated the position of the object at time 0.5");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Time_ChangesWith_GameTime([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
float previousTime = Time.time;
|
||||
yield return null;
|
||||
yield return null; //Since the Animation Component doesn't update the time on the first frame, we must wait two frames to see an effect
|
||||
float elapsedTime = Time.time - previousTime;
|
||||
Assert.AreNotEqual(elapsedTime, state.time, "State time should have changed");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Time_SetPast_ClipEnd_StopsState_AfterOneFrame([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
state.time = 2.0f;
|
||||
yield return null;
|
||||
Assert.IsFalse(state.enabled, "State should be disabled");
|
||||
Assert.IsFalse(animation.IsPlaying(state.name), "State should be disabled");
|
||||
Assert.IsFalse(animation.isPlaying, "State should be disabled");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Time_SetPast_ClipEnd_ThenBack_DoesntStopState([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
state.time = 2.0f;
|
||||
state.time = 0.2f;
|
||||
yield return null;
|
||||
Assert.IsTrue(state.enabled, "State should be enabled");
|
||||
Assert.IsTrue(animation.IsPlaying(state.name), "State should be playing");
|
||||
Assert.IsTrue(animation.isPlaying, "Component should be playing");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Time_SetPast_ClipEnd_Doesnt_Immediately_StopState([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
state.time = 2.0f;
|
||||
Assert.IsTrue(state.enabled, "State should be enabled");
|
||||
Assert.IsTrue(animation.IsPlaying(state.name), "State should be playing");
|
||||
Assert.IsTrue(animation.isPlaying, "Component should be playing");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Time_SetTime_DoesntStartState([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
state.time = 2.0f;
|
||||
state.time = 0.2f;
|
||||
yield return null;
|
||||
Assert.IsTrue(state.enabled, "State should be disabled");
|
||||
Assert.IsTrue(animation.IsPlaying(state.name), "State should be disabled");
|
||||
Assert.IsTrue(animation.isPlaying, "State should be disabled");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Time_SetTime_DoesntPlayEvents([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("FiresEvent");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
var eventReceiver = animation.gameObject.AddComponent<SimpleAnimationTests.ReceivesEvent>();
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
state.time = 0.1f;
|
||||
yield return null;
|
||||
Assert.AreEqual(0, eventReceiver.eventCount, "Event should not have been received");
|
||||
state.time = 0.6f;
|
||||
yield return null;
|
||||
Assert.AreEqual(0, eventReceiver.eventCount, "Event should have been received after setting the time on the state");
|
||||
}
|
||||
}
|
||||
|
||||
public class NormalizedTime
|
||||
{
|
||||
[Test]
|
||||
public void State_NormalizedTime_AffectsTime([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
//Create event to extend clip
|
||||
var evt = new AnimationEvent();
|
||||
evt.time = 2.0f;
|
||||
clipInstance.AddEvent(evt);
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.normalizedTime = 0.5f;
|
||||
Assert.AreEqual(state.normalizedTime*state.length, state.time);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Time_AffectsNormalizedTime([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
//Create event to extend clip
|
||||
var evt = new AnimationEvent();
|
||||
evt.time = 2.0f;
|
||||
clipInstance.AddEvent(evt);
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.time = 0.5f;
|
||||
Assert.AreEqual(state.time / state.length, state.normalizedTime);
|
||||
}
|
||||
}
|
||||
|
||||
public class Enabled
|
||||
{
|
||||
[Test]
|
||||
public void State_Enabled_InitialValue_False([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
Assert.IsFalse(state.enabled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Enabled_SetTrue_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.enabled = true;
|
||||
Assert.IsTrue(state.enabled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Enabled_AfterPlay_ReturnsTrue([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
Assert.IsTrue(state.enabled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Enabled_AfterStop_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.enabled = true;
|
||||
animation.Stop(state.name);
|
||||
Assert.IsFalse(state.enabled);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Enabled_AfterStateEnd_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.enabled = true;
|
||||
yield return new WaitForSeconds(1.1f);
|
||||
|
||||
Assert.IsFalse(state.enabled);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Enabled_AfterSetTime_ToStateEnd_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.enabled = true;
|
||||
state.time = 2f;
|
||||
yield return null;
|
||||
Assert.IsFalse(state.enabled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Enabled_False_IsPlaying_ReturnsFalse([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
animation.Play(state.name);
|
||||
state.enabled = false;
|
||||
Assert.IsFalse(animation.isPlaying);
|
||||
Assert.IsFalse(animation.IsPlaying(state.name));
|
||||
}
|
||||
}
|
||||
|
||||
public class Speed
|
||||
{
|
||||
[UnityTest]
|
||||
public IEnumerator State_Speed_SetTo_Zero_Time_DoesntAdvance([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.speed = 0f;
|
||||
state.enabled = true;
|
||||
yield return null;
|
||||
yield return null; //Second frame to allow Animation Component to advance time
|
||||
Assert.AreEqual(0f, state.time);
|
||||
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Speed_Negative_StopsState_WhenTime_Reaches_Negative([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.speed = -1f;
|
||||
state.enabled = true;
|
||||
yield return null;
|
||||
yield return null; //Second frame to allow Animation Component to advance time
|
||||
Assert.IsFalse(state.enabled);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Speed_Negative_DoesntStopsState_WhenTime_Reaches_Negative_OnLoopedClip([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
clipInstance.wrapMode = WrapMode.Loop;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.speed = -1f;
|
||||
state.enabled = true;
|
||||
yield return null;
|
||||
yield return null; //Second frame to allow Animation Component to advance time
|
||||
Assert.IsTrue(state.enabled);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Speed_DoesntAffect_NormalizedTime([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
clipInstance.wrapMode = WrapMode.Loop;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.time = 0.5f;
|
||||
float normalizedTime = state.normalizedTime;
|
||||
state.speed = 10.0f;
|
||||
Assert.AreEqual(normalizedTime, state.normalizedTime);
|
||||
}
|
||||
}
|
||||
|
||||
public class Name
|
||||
{
|
||||
[Test]
|
||||
public void State_Name_Equals_AddClip_Name([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
Assert.AreEqual("ValidName", state.name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Name_ChangingName_Name_Equals_NewName([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.name = "NewName";
|
||||
Assert.AreEqual("NewName", state.name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Name_ChangingName_DoesntInvalidate_State([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.name = "NewName";
|
||||
Assert.IsTrue(state.isValid);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Name_RenamedState_CantBeFound_ByOldName([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.name = "NewName";
|
||||
state = animation.GetState("ValidName");
|
||||
Assert.IsNull(state);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Name_RenamedState_CanBeFound_ByNewName([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.name = "NewName";
|
||||
state = animation.GetState("NewName");
|
||||
Assert.IsNotNull(state);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Name_EmptyString_CanBeFound([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.name = "";
|
||||
state = animation.GetState("");
|
||||
Assert.IsNotNull(state);
|
||||
}
|
||||
}
|
||||
|
||||
public class Weight
|
||||
{
|
||||
[UnityTest]
|
||||
public IEnumerator State_Weight_EqualZero_DoesntWrite([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.enabled = true;
|
||||
state.weight = 0f;
|
||||
state.time = 0.5f; //Seek the clip so that values should be written;
|
||||
yield return null;
|
||||
Assert.AreEqual(0f, animation.gameObject.transform.localPosition.x);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Weight_FlipFlopTest([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.enabled = true;
|
||||
state.weight = 0f;
|
||||
state.time = 0.5f; //Seek the clip so that values should be written;
|
||||
yield return null;
|
||||
Assert.AreEqual(0f, animation.gameObject.transform.localPosition.x);
|
||||
state.weight = 1f;
|
||||
yield return null;
|
||||
Assert.AreNotEqual(0f, animation.gameObject.transform.localPosition.x);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Weight_Normalizes([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clip2 = Resources.Load<AnimationClip>("LinearY");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
var clipInstance2 = Object.Instantiate<AnimationClip>(clip2);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
clipInstance2.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "State1");
|
||||
animation.AddClip(clipInstance2, "State2");
|
||||
IAnimationState state1 = animation.GetState("State1");
|
||||
IAnimationState state2 = animation.GetState("State2");
|
||||
state1.enabled = true;
|
||||
state2.enabled = true;
|
||||
state1.weight = 1f;
|
||||
state2.weight = 1f;
|
||||
state1.time = 0.5f; //Seek the clip so that values should be written;
|
||||
state2.time = 0.5f; //Seek the clip so that values should be written;
|
||||
yield return null;
|
||||
Assert.AreEqual(0.25f, animation.gameObject.transform.localPosition.x);
|
||||
Assert.AreEqual(0.25f, animation.gameObject.transform.localPosition.y);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator State_Weight_NonZero_Writes([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.enabled = true;
|
||||
state.weight = 1f;
|
||||
state.time = 0.5f; //Seek the clip so that values should be written;
|
||||
yield return null;
|
||||
Assert.AreNotEqual(0f, animation.gameObject.transform.localPosition.x);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Weight_SetWeight_Equals_GetWeight([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.weight = 1f;
|
||||
Assert.AreEqual(1f, state.weight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Weight_InitialValue_IsZero([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
Assert.AreEqual(0f, state.weight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Weight_SetEnable_DoesntChange_Weight([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.enabled = true;
|
||||
Assert.AreEqual(0f, state.weight);
|
||||
state.weight = 1f;
|
||||
state.enabled = false;
|
||||
Assert.AreEqual(1f, state.weight);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void State_Weight_SetWeight_DoesntChange_Enable([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
state.weight = 1f;
|
||||
Assert.IsFalse(state.enabled);
|
||||
state.enabled = true;
|
||||
state.weight = 0f;
|
||||
Assert.IsTrue(state.enabled);
|
||||
}
|
||||
}
|
||||
|
||||
public class Length
|
||||
{
|
||||
[Test]
|
||||
public void State_Length_Equals_ClipLength([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, "ValidName");
|
||||
IAnimationState state = animation.GetState("ValidName");
|
||||
Assert.AreEqual(clipInstance.length, state.length);
|
||||
}
|
||||
}
|
||||
|
||||
public class Clip
|
||||
{
|
||||
[Test]
|
||||
public void State_Clip_Equals_SetClip([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, clipInstance.name);
|
||||
IAnimationState state = animation.GetState(clipInstance.name);
|
||||
Assert.AreEqual(clipInstance, state.clip);
|
||||
}
|
||||
}
|
||||
|
||||
public class WrapModeTests
|
||||
{
|
||||
[Test]
|
||||
public void WrapMode_Equals_Clip_WrapMode([ValueSource(typeof(ComparativeTestFixture), "Sources")]System.Type type)
|
||||
{
|
||||
IAnimation animation = ComparativeTestFixture.Instantiate(type);
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
clipInstance.legacy = animation.usesLegacy;
|
||||
|
||||
animation.AddClip(clipInstance, clipInstance.name);
|
||||
IAnimationState state = animation.GetState(clipInstance.name);
|
||||
Assert.AreEqual(clipInstance.wrapMode, state.wrapMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8cb3c934bf3f0534a8b954abe8c4984d
|
||||
timeCreated: 1498676303
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e443d0a02c421de4381e52acca42b6b8
|
||||
folderAsset: yes
|
||||
timeCreated: 1494560892
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,67 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!74 &7400000
|
||||
AnimationClip:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: FiresEvent
|
||||
serializedVersion: 6
|
||||
m_Legacy: 0
|
||||
m_Compressed: 0
|
||||
m_UseHighQualityCurve: 1
|
||||
m_RotationCurves: []
|
||||
m_CompressedRotationCurves: []
|
||||
m_EulerCurves: []
|
||||
m_PositionCurves: []
|
||||
m_ScaleCurves: []
|
||||
m_FloatCurves: []
|
||||
m_PPtrCurves: []
|
||||
m_SampleRate: 60
|
||||
m_WrapMode: 0
|
||||
m_Bounds:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0, y: 0, z: 0}
|
||||
m_ClipBindingConstant:
|
||||
genericBindings: []
|
||||
pptrCurveMapping: []
|
||||
m_AnimationClipSettings:
|
||||
serializedVersion: 2
|
||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||
m_AdditiveReferencePoseTime: 0
|
||||
m_StartTime: 0
|
||||
m_StopTime: 1
|
||||
m_OrientationOffsetY: 0
|
||||
m_Level: 0
|
||||
m_CycleOffset: 0
|
||||
m_HasAdditiveReferencePose: 0
|
||||
m_LoopTime: 0
|
||||
m_LoopBlend: 0
|
||||
m_LoopBlendOrientation: 0
|
||||
m_LoopBlendPositionY: 0
|
||||
m_LoopBlendPositionXZ: 0
|
||||
m_KeepOriginalOrientation: 0
|
||||
m_KeepOriginalPositionY: 1
|
||||
m_KeepOriginalPositionXZ: 0
|
||||
m_HeightFromFeet: 0
|
||||
m_Mirror: 0
|
||||
m_EditorCurves: []
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_GenerateMotionCurves: 0
|
||||
m_Events:
|
||||
- time: 0.4
|
||||
functionName: Event
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 1
|
||||
functionName: Event
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6daa07941d12d35499204edaf3412a35
|
||||
timeCreated: 1519669948
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,145 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!74 &7400000
|
||||
AnimationClip:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: LinearX
|
||||
serializedVersion: 6
|
||||
m_Legacy: 0
|
||||
m_Compressed: 0
|
||||
m_UseHighQualityCurve: 1
|
||||
m_RotationCurves: []
|
||||
m_CompressedRotationCurves: []
|
||||
m_EulerCurves: []
|
||||
m_PositionCurves:
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: {x: 0, y: 0, z: 0}
|
||||
inSlope: {x: Infinity, y: Infinity, z: Infinity}
|
||||
outSlope: {x: 1, y: 0, z: 0}
|
||||
tangentMode: 0
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: {x: 1, y: 0, z: 0}
|
||||
inSlope: {x: 1, y: -0, z: -0}
|
||||
outSlope: {x: Infinity, y: Infinity, z: Infinity}
|
||||
tangentMode: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
path:
|
||||
m_ScaleCurves: []
|
||||
m_FloatCurves: []
|
||||
m_PPtrCurves: []
|
||||
m_SampleRate: 60
|
||||
m_WrapMode: 1
|
||||
m_Bounds:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0, y: 0, z: 0}
|
||||
m_ClipBindingConstant:
|
||||
genericBindings:
|
||||
- serializedVersion: 2
|
||||
path: 0
|
||||
attribute: 1
|
||||
script: {fileID: 0}
|
||||
typeID: 4
|
||||
customType: 0
|
||||
isPPtrCurve: 0
|
||||
pptrCurveMapping: []
|
||||
m_AnimationClipSettings:
|
||||
serializedVersion: 2
|
||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||
m_AdditiveReferencePoseTime: 0
|
||||
m_StartTime: 0
|
||||
m_StopTime: 1
|
||||
m_OrientationOffsetY: 0
|
||||
m_Level: 0
|
||||
m_CycleOffset: 0
|
||||
m_HasAdditiveReferencePose: 0
|
||||
m_LoopTime: 1
|
||||
m_LoopBlend: 0
|
||||
m_LoopBlendOrientation: 0
|
||||
m_LoopBlendPositionY: 0
|
||||
m_LoopBlendPositionXZ: 0
|
||||
m_KeepOriginalOrientation: 0
|
||||
m_KeepOriginalPositionY: 1
|
||||
m_KeepOriginalPositionXZ: 0
|
||||
m_HeightFromFeet: 0
|
||||
m_Mirror: 0
|
||||
m_EditorCurves:
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: Infinity
|
||||
outSlope: 1
|
||||
tangentMode: 69
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 1
|
||||
outSlope: Infinity
|
||||
tangentMode: 69
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.x
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: Infinity
|
||||
outSlope: 0
|
||||
tangentMode: 69
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: -0
|
||||
outSlope: Infinity
|
||||
tangentMode: 69
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.y
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: Infinity
|
||||
outSlope: 0
|
||||
tangentMode: 69
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: -0
|
||||
outSlope: Infinity
|
||||
tangentMode: 69
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.z
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 1
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_GenerateMotionCurves: 0
|
||||
m_Events: []
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfc925af54b7a044bbc0364b9157fc0d
|
||||
timeCreated: 1492542614
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,138 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!74 &7400000
|
||||
AnimationClip:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: LinearXLegacy
|
||||
serializedVersion: 6
|
||||
m_Legacy: 1
|
||||
m_Compressed: 0
|
||||
m_UseHighQualityCurve: 1
|
||||
m_RotationCurves: []
|
||||
m_CompressedRotationCurves: []
|
||||
m_EulerCurves: []
|
||||
m_PositionCurves:
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: {x: 0, y: 0, z: 0}
|
||||
inSlope: {x: Infinity, y: Infinity, z: Infinity}
|
||||
outSlope: {x: 1, y: 0, z: 0}
|
||||
tangentMode: 0
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: {x: 1, y: 0, z: 0}
|
||||
inSlope: {x: 1, y: -0, z: -0}
|
||||
outSlope: {x: Infinity, y: Infinity, z: Infinity}
|
||||
tangentMode: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
path:
|
||||
m_ScaleCurves: []
|
||||
m_FloatCurves: []
|
||||
m_PPtrCurves: []
|
||||
m_SampleRate: 60
|
||||
m_WrapMode: 1
|
||||
m_Bounds:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0, y: 0, z: 0}
|
||||
m_ClipBindingConstant:
|
||||
genericBindings: []
|
||||
pptrCurveMapping: []
|
||||
m_AnimationClipSettings:
|
||||
serializedVersion: 2
|
||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||
m_AdditiveReferencePoseTime: 0
|
||||
m_StartTime: 0
|
||||
m_StopTime: 1
|
||||
m_OrientationOffsetY: 0
|
||||
m_Level: 0
|
||||
m_CycleOffset: 0
|
||||
m_HasAdditiveReferencePose: 0
|
||||
m_LoopTime: 1
|
||||
m_LoopBlend: 0
|
||||
m_LoopBlendOrientation: 0
|
||||
m_LoopBlendPositionY: 0
|
||||
m_LoopBlendPositionXZ: 0
|
||||
m_KeepOriginalOrientation: 0
|
||||
m_KeepOriginalPositionY: 1
|
||||
m_KeepOriginalPositionXZ: 0
|
||||
m_HeightFromFeet: 0
|
||||
m_Mirror: 0
|
||||
m_EditorCurves:
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: Infinity
|
||||
outSlope: 1
|
||||
tangentMode: 69
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 1
|
||||
outSlope: Infinity
|
||||
tangentMode: 69
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.x
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: Infinity
|
||||
outSlope: 0
|
||||
tangentMode: 69
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: -0
|
||||
outSlope: Infinity
|
||||
tangentMode: 69
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.y
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: Infinity
|
||||
outSlope: 0
|
||||
tangentMode: 69
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: -0
|
||||
outSlope: Infinity
|
||||
tangentMode: 69
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.z
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 1
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_GenerateMotionCurves: 0
|
||||
m_Events: []
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e7cf6bd5ccd3f74e827f886ea59f0b1
|
||||
timeCreated: 1507816446
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,145 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!74 &7400000
|
||||
AnimationClip:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: LinearY
|
||||
serializedVersion: 6
|
||||
m_Legacy: 0
|
||||
m_Compressed: 0
|
||||
m_UseHighQualityCurve: 1
|
||||
m_RotationCurves: []
|
||||
m_CompressedRotationCurves: []
|
||||
m_EulerCurves: []
|
||||
m_PositionCurves:
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: {x: 0, y: 0, z: 0}
|
||||
inSlope: {x: 0, y: 0, z: 0}
|
||||
outSlope: {x: 0, y: 1, z: 0}
|
||||
tangentMode: 0
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: {x: 0, y: 1, z: 0}
|
||||
inSlope: {x: -0, y: 1, z: -0}
|
||||
outSlope: {x: 0, y: 0, z: 0}
|
||||
tangentMode: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
path:
|
||||
m_ScaleCurves: []
|
||||
m_FloatCurves: []
|
||||
m_PPtrCurves: []
|
||||
m_SampleRate: 60
|
||||
m_WrapMode: 0
|
||||
m_Bounds:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0, y: 0, z: 0}
|
||||
m_ClipBindingConstant:
|
||||
genericBindings:
|
||||
- serializedVersion: 2
|
||||
path: 0
|
||||
attribute: 1
|
||||
script: {fileID: 0}
|
||||
typeID: 4
|
||||
customType: 0
|
||||
isPPtrCurve: 0
|
||||
pptrCurveMapping: []
|
||||
m_AnimationClipSettings:
|
||||
serializedVersion: 2
|
||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||
m_AdditiveReferencePoseTime: 0
|
||||
m_StartTime: 0
|
||||
m_StopTime: 1
|
||||
m_OrientationOffsetY: 0
|
||||
m_Level: 0
|
||||
m_CycleOffset: 0
|
||||
m_HasAdditiveReferencePose: 0
|
||||
m_LoopTime: 1
|
||||
m_LoopBlend: 0
|
||||
m_LoopBlendOrientation: 0
|
||||
m_LoopBlendPositionY: 0
|
||||
m_LoopBlendPositionXZ: 0
|
||||
m_KeepOriginalOrientation: 0
|
||||
m_KeepOriginalPositionY: 1
|
||||
m_KeepOriginalPositionXZ: 0
|
||||
m_HeightFromFeet: 0
|
||||
m_Mirror: 0
|
||||
m_EditorCurves:
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 69
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: -0
|
||||
outSlope: 0
|
||||
tangentMode: 69
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.x
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 1
|
||||
tangentMode: 69
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 1
|
||||
outSlope: 0
|
||||
tangentMode: 69
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.y
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 69
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: -0
|
||||
outSlope: 0
|
||||
tangentMode: 69
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.z
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 1
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_GenerateMotionCurves: 0
|
||||
m_Events: []
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6ad4075bbce8ce4d8f9a0d44b3328f4
|
||||
timeCreated: 1492542687
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,145 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!74 &7400000
|
||||
AnimationClip:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: LinearZ
|
||||
serializedVersion: 6
|
||||
m_Legacy: 0
|
||||
m_Compressed: 0
|
||||
m_UseHighQualityCurve: 1
|
||||
m_RotationCurves: []
|
||||
m_CompressedRotationCurves: []
|
||||
m_EulerCurves: []
|
||||
m_PositionCurves:
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: {x: 0, y: 0, z: 0}
|
||||
inSlope: {x: 0, y: 0, z: 0}
|
||||
outSlope: {x: 0, y: 0, z: 0}
|
||||
tangentMode: 0
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: {x: 0, y: 0, z: 1}
|
||||
inSlope: {x: 0, y: 0, z: 0}
|
||||
outSlope: {x: 0, y: 0, z: 0}
|
||||
tangentMode: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
path:
|
||||
m_ScaleCurves: []
|
||||
m_FloatCurves: []
|
||||
m_PPtrCurves: []
|
||||
m_SampleRate: 60
|
||||
m_WrapMode: 0
|
||||
m_Bounds:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0, y: 0, z: 0}
|
||||
m_ClipBindingConstant:
|
||||
genericBindings:
|
||||
- serializedVersion: 2
|
||||
path: 0
|
||||
attribute: 1
|
||||
script: {fileID: 0}
|
||||
typeID: 4
|
||||
customType: 0
|
||||
isPPtrCurve: 0
|
||||
pptrCurveMapping: []
|
||||
m_AnimationClipSettings:
|
||||
serializedVersion: 2
|
||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||
m_AdditiveReferencePoseTime: 0
|
||||
m_StartTime: 0
|
||||
m_StopTime: 1
|
||||
m_OrientationOffsetY: 0
|
||||
m_Level: 0
|
||||
m_CycleOffset: 0
|
||||
m_HasAdditiveReferencePose: 0
|
||||
m_LoopTime: 1
|
||||
m_LoopBlend: 0
|
||||
m_LoopBlendOrientation: 0
|
||||
m_LoopBlendPositionY: 0
|
||||
m_LoopBlendPositionXZ: 0
|
||||
m_KeepOriginalOrientation: 0
|
||||
m_KeepOriginalPositionY: 1
|
||||
m_KeepOriginalPositionXZ: 0
|
||||
m_HeightFromFeet: 0
|
||||
m_Mirror: 0
|
||||
m_EditorCurves:
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.x
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.y
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 2
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
- serializedVersion: 2
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 136
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_LocalPosition.z
|
||||
path:
|
||||
classID: 4
|
||||
script: {fileID: 0}
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 1
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_GenerateMotionCurves: 0
|
||||
m_Events: []
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b6ab153d3e5b6441b29261e07fbc9c4
|
||||
timeCreated: 1492542878
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &8787524063794857361
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8787524063794857368}
|
||||
- component: {fileID: 8787524063794857371}
|
||||
- component: {fileID: 8787524063794857370}
|
||||
- component: {fileID: 8787524063794857365}
|
||||
- component: {fileID: 8787524063794857367}
|
||||
- component: {fileID: 8787524063794857366}
|
||||
m_Layer: 0
|
||||
m_Name: WithSimpleAnimation
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &8787524063794857368
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8787524063794857361}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &8787524063794857371
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8787524063794857361}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &8787524063794857370
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8787524063794857361}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!65 &8787524063794857365
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8787524063794857361}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!95 &8787524063794857367
|
||||
Animator:
|
||||
serializedVersion: 3
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8787524063794857361}
|
||||
m_Enabled: 1
|
||||
m_Avatar: {fileID: 0}
|
||||
m_Controller: {fileID: 0}
|
||||
m_CullingMode: 1
|
||||
m_UpdateMode: 0
|
||||
m_ApplyRootMotion: 0
|
||||
m_LinearVelocityBlending: 0
|
||||
m_WarningMessage:
|
||||
m_HasTransformHierarchy: 1
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
m_KeepAnimatorControllerStateOnDisable: 0
|
||||
--- !u!114 &8787524063794857366
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8787524063794857361}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3759e2aae0f7b9a47bb98fc64bf3c543, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_PlayAutomatically: 1
|
||||
m_AnimatePhysics: 0
|
||||
m_CullingMode: 1
|
||||
m_WrapMode: 0
|
||||
m_Clip: {fileID: 0}
|
||||
m_States:
|
||||
- clip: {fileID: 0}
|
||||
name: Default
|
||||
defaultState: 1
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e932bd603cbef5540ad872fdcd320722
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using Object = UnityEngine.Object;
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
|
||||
public class SimpleAnimationTests
|
||||
{
|
||||
static SimpleAnimation Instantiate()
|
||||
{
|
||||
var go = new GameObject();
|
||||
return go.AddComponent<SimpleAnimation>();
|
||||
}
|
||||
public class GetStates
|
||||
{
|
||||
[Test]
|
||||
public void GetStates_WithNoStates_IEnumerator_MoveNext_ReturnsFalse()
|
||||
{
|
||||
SimpleAnimation animation = Instantiate();
|
||||
IEnumerable<SimpleAnimation.State> states = animation.GetStates();
|
||||
var it = states.GetEnumerator();
|
||||
Assert.IsFalse(it.MoveNext());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetStates_WithNoStates_IEnumerator_Current_Throws()
|
||||
{
|
||||
SimpleAnimation animation = Instantiate();
|
||||
IEnumerable<SimpleAnimation.State> states = animation.GetStates();
|
||||
var it = states.GetEnumerator();
|
||||
Assert.Throws<InvalidOperationException>(() => { SimpleAnimation.State state = it.Current; });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetStates_WithSingleState_IEnumerator_Returns_ValidState()
|
||||
{
|
||||
SimpleAnimation animation = Instantiate();
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
|
||||
animation.AddClip(clipInstance, "SingleClip");
|
||||
IEnumerable<SimpleAnimation.State> states = animation.GetStates();
|
||||
var it = states.GetEnumerator();
|
||||
it.MoveNext();
|
||||
SimpleAnimation.State state = it.Current;
|
||||
Assert.AreEqual("SingleClip", state.name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetStates_ModifyStates_IEnumerator_MoveNext_Throws()
|
||||
{
|
||||
SimpleAnimation animation = Instantiate();
|
||||
var clip = Resources.Load<AnimationClip>("LinearX");
|
||||
var clipInstance = Object.Instantiate<AnimationClip>(clip);
|
||||
|
||||
animation.AddClip(clipInstance, "SingleClip");
|
||||
IEnumerable<SimpleAnimation.State> states = animation.GetStates();
|
||||
var it = states.GetEnumerator();
|
||||
animation.RemoveState("SingleClip");
|
||||
Assert.Throws<InvalidOperationException>(() => { it.MoveNext(); });
|
||||
}
|
||||
}
|
||||
|
||||
public class PrefabBased
|
||||
{
|
||||
[UnityTest]
|
||||
public IEnumerator PlayAutomatically_False_DoesNotMoveObject()
|
||||
{
|
||||
var prefab = Resources.Load<GameObject>("WithSimpleAnimation");
|
||||
var simpleAnim = prefab.GetComponent<SimpleAnimation>();
|
||||
simpleAnim.playAutomatically = false;
|
||||
var instance = GameObject.Instantiate<GameObject>(prefab);
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
Assert.Zero(instance.transform.position.magnitude);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator PlayAutomatically_True_DoesMoveObject()
|
||||
{
|
||||
var prefab = Resources.Load<GameObject>("WithSimpleAnimation");
|
||||
prefab.GetComponent<SimpleAnimation>().playAutomatically = true;
|
||||
var instance = GameObject.Instantiate<GameObject>(prefab);
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
Assert.Zero(instance.transform.position.magnitude);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class LegacyClips
|
||||
{
|
||||
[Test]
|
||||
public void SetClip_WithLegacyClip_Throws_ArgumentException()
|
||||
{
|
||||
SimpleAnimation animation = Instantiate();
|
||||
var clip = new AnimationClip();
|
||||
clip.legacy = true;
|
||||
Assert.Throws<ArgumentException>(() => { animation.clip = clip; });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddClip_WithLegacyClip_Throws_ArgumentException()
|
||||
{
|
||||
SimpleAnimation animation = Instantiate();
|
||||
var clip = new AnimationClip();
|
||||
clip.legacy = true;
|
||||
Assert.Throws<ArgumentException>(() => { animation.AddClip(clip, "DefaultName");});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddState_WithLegacyClip_Throws_ArgumentException()
|
||||
{
|
||||
SimpleAnimation animation = Instantiate();
|
||||
var clip = new AnimationClip();
|
||||
clip.legacy = true;
|
||||
Assert.Throws<ArgumentException>(() => { animation.AddState(clip, "DefaultName"); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Event Receiver for FiresEvent AnimationClip
|
||||
public class ReceivesEvent : MonoBehaviour
|
||||
{
|
||||
public int eventCount;
|
||||
|
||||
void Event()
|
||||
{
|
||||
eventCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c4dfe8c4d18124458dbd9a5c201a9f2
|
||||
timeCreated: 1502400329
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user