Version: 2017.1

Assert.AreNotApproximatelyEqual

切换到手册
public static void AreNotApproximatelyEqual (float expected, float actual);
public static void AreNotApproximatelyEqual (float expected, float actual, string message);
public static void AreNotApproximatelyEqual (float expected, float actual, float tolerance);
public static void AreNotApproximatelyEqual (float expected, float actual, float tolerance, string message);

参数

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); } }