public void Test_OnAnimate_Event_2() { var clip = new AnimationClip (100, "TestClip"); clip.WrapMode = WrapMode.Once; clip.Play (); var args1 = new MyEventArgs (1); var args2 = new MyEventArgs (2); var args3 = new MyEventArgs (3); var count = 0; clip.AddEvent (0, (sender, args) => count = 1, null); clip.AddEvent (50, (sender, args) => count = 2, null); clip.AddEvent (100, (sender, args) => count += 1, null); clip.AddEvent (100, (sender, args) => count += 1, null); var anim = new AnimationController (); anim.AddClip (clip); // 停止中のクリップはイベントを発火しない clip.Stop (); anim.OnAnimate (0, 0); Assert.AreEqual (0, count); clip.Play (); // 逆再生中の dtime は逆方向 // clip.SetSpeed (-1, 50); // anim.OnAnimate (40, 10); // Assert.AreEqual (2, count); count = 0; clip.Speed = 1; // 同じポジションで重複したイベントは両方発火 anim.OnAnimate (100, 0); Assert.AreEqual (2, count); }
public void Test_OnAnimate_Event_Args() { var clip = new AnimationClip (100, "TestClip"); clip.WrapMode = WrapMode.Once; clip.Play (); var args1 = new MyEventArgs (1); var args2 = new MyEventArgs (2); var args3 = new MyEventArgs (3); var count = 0; clip.AddEvent (0, (sender, args) => count = ((MyEventArgs)args).Value, args1); clip.AddEvent (50, (sender, args) => count = ((MyEventArgs)args).Value, args2); clip.AddEvent (100, (sender, args) => count = ((MyEventArgs)args).Value, args3); var anim = new AnimationController (); anim.AddClip (clip); anim.OnAnimate (0, 0); Assert.AreEqual (1, count); anim.OnAnimate (50, 0); Assert.AreEqual (2, count); anim.OnAnimate (100, 0); Assert.AreEqual (3, count); }