-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple test to ensure spline cart is working correctly (#1002)
- Loading branch information
1 parent
c90babd
commit 155139f
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
using UnityEngine.Splines; | ||
using Unity.Mathematics; | ||
|
||
namespace Unity.Cinemachine.Tests | ||
{ | ||
[TestFixture] | ||
public class CinemachineSplineCartTest : CinemachineRuntimeFixtureBase | ||
{ | ||
CinemachineSplineCart m_CmSplineCart; | ||
SplineContainer m_SplineContainer; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
base.SetUp(); | ||
|
||
m_SplineContainer = CreateGameObject("Dolly Track", typeof(SplineContainer)).GetComponent<SplineContainer>(); | ||
m_SplineContainer.Spline = SplineFactory.CreateLinear( | ||
new List<float3> { new(7, 1, -6), new(13, 1, -6), new(13, 1, 1), new(7, 1, 1) }, true); | ||
m_CmSplineCart = CreateGameObject("CM cart", typeof(CinemachineSplineCart)).GetComponent<CinemachineSplineCart>(); | ||
m_CmSplineCart.Spline = m_SplineContainer; | ||
} | ||
|
||
[TearDown] | ||
public override void TearDown() | ||
{ | ||
base.TearDown(); | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator CartPositionIsCorrect() | ||
{ | ||
m_CmSplineCart.PositionUnits = PathIndexUnit.Distance; | ||
m_CmSplineCart.SplinePosition = 0; | ||
yield return null; | ||
UnityEngine.Assertions.Assert.AreApproximatelyEqual( | ||
Vector3.Distance(m_CmSplineCart.transform.position, new Vector3(7, 1, -6)), 0, 0.1f); | ||
|
||
m_CmSplineCart.PositionUnits = PathIndexUnit.Normalized; | ||
m_CmSplineCart.SplinePosition = 1; | ||
yield return null; | ||
UnityEngine.Assertions.Assert.AreApproximatelyEqual( | ||
Vector3.Distance(m_CmSplineCart.transform.position, new Vector3(7, 1, -6)), 0, 0.1f); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
com.unity.cinemachine/Tests/Runtime/SplineCartTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.