tolerance | 近似公差。 |
断言值近似不相等。使用绝对错误检查执行近似相等性检查(|a-b| < 公差)。默认公差为 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); } }