Version: 2017.2

描述

该对象是否存在?

下面的两个示例将给出相同的结果。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { if (rigidbody) Debug.Log("Rigidbody attached to this transform"); } }

...等同于...

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { if (rigidbody != null) Debug.Log("Rigidbody attached to this transform"); } }