An extension method for Assert.AreApproximatelyEqual.
using UnityEngine; using UnityEngine.Assertions; using UnityEngine.Assertions.Must;
public class AssertionExampleClass : MonoBehaviour { void Update() { //Make sure the position of the GameObject is always in the center of the Scene. //MustBeApproximatelyEqual should be used for comparing floating point variables. //Unless specified, default error tolerance will be used. transform.position.x.MustBeApproximatelyEqual(0.0f); transform.position.y.MustBeApproximatelyEqual(0.0f); transform.position.z.MustBeApproximatelyEqual(0.0f); } }