断言该值近似不等于。
绝对误差检查用于近似相等性检查(|a-b| < tolerance)。默认容差为 0.00001f。
using UnityEngine; using UnityEngine.Assertions;
public class AssertionExampleClass : MonoBehaviour { Rigidbody rb;
void Update() { // Make sure the rigidbody never stops. // AreNotApproximatelyEqual should be used for comparing floating point variables. // Unless specified, default error tolerance will be used. Assert.AreNotApproximatelyEqual(0.0f, rb.velocity.magnitude); } }