Version: 5.4
public static bool operator == (Object x, Object y);

Parámetros

x El primer objeto.
y El objeto a comparar contrar el primero.

Descripción

Compara dos referencias de objeto para ver si se refieren al mismo objeto.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Collider target; void OnTriggerEnter(Collider trigger) { if (trigger == target) print("We hit the target trigger"); } }

Obtener temprano si no hay un objetivo.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform target; void Update() { if (target == null) return; } }

Tenga cuidado cuando compare con null.

p.ej.

GameObject go = new GameObject(); 
Debug.Log (go == null); // false

Object obj = new Object(); Debug.Log (obj == null); // true

Instanciar un GameObject lo agrega a la escena por lo que es completamente inicializado (!Destruido). Instanciar un simple UnityEngine.Object no tiene tal semántica, por lo que permanece en el estado 'destruido' que compara true a null.