Version: 2017.2
Method group is Obsolete

MustExtensions

class in UnityEngine.Assertions.Must

切换到手册
Obsolete

描述

用作 Assert 类的包装器的扩展类。

MustExtension 类将 Assertion.Assert 包裹成更具可读性且更短的语法。

using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Assertions.Must;

public class ExampleClass : MonoBehaviour { public int health; public GameObject go; void Update() { //This assertion Assert.AreNotEqual(0, health); //can be also written like this health.MustNotBeEqual(0);

//Same with this assertion Assert.IsTrue(go.activeInHierarchy); //can be also written like this go.activeInHierarchy.MustBeTrue(); } }