Object.operator ==

static operator == (x : Object, y : Object) : boolean

Description

Compares if two objects refer to the same.

JavaScript
    var target : Collider;
function OnTriggerEnter (trigger : Collider) {
if (trigger == target)
print("We hit the target trigger");
}

using UnityEngine;
using System.Collections;

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

}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

public target as Collider

def OnTriggerEnter(trigger as Collider):
if trigger == target:
print('We hit the target trigger')

Get early out if there is no target.
JavaScript
    var target : Transform;
function Update () {
// Early out if the target is gone
if (target == null)
return;
}

using UnityEngine;
using System.Collections;

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

}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

public target as Transform

def Update():
if target == null:
return