\$\begingroup\$You can also create a GameObject member variable and assign it via the editor. This works when assigning an inactive object, while GameObject.Find() doesn't.\$\endgroup\$
– Panda PajamaJul 23 '13 at 5:09

1

\$\begingroup\$@PandaPajama I think this warrants a separate answer. The member-variable and assigning via editor approach is much more flexible and easier to read. Somebody looking for an answer to this problem should really have this as an answer.\$\endgroup\$
– bummzackJul 23 '13 at 6:49

\$\begingroup\$I agree. While the approach mentioned in this answer works, it is fairly brittle (eg. you can't reuse the script with other objects) and so the other approach is preferred.\$\endgroup\$
– jhockingJul 18 '14 at 11:47

Let's assume you write a behavior for your Camera and name it CameraController. Here's how this could look like:

using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
// this will turn up in the Inspector where you can assign
// an object to CameraTarget and use it later in your code.
public GameObject CameraTarget;
void Update () {
// update position while looking at CameraTarget
Vector3 pos = transform.position;
pos.z += Time.deltaTime;
transform.position = pos;
transform.LookAt(CameraTarget.transform);
}
}

Once you add this script to your camera (or any other game-object for that matter), the CameraTarget it will show up in the "Inspector" as soon as you select this object. Then you can drag'n'drop any object from your scene or even your assets panel (think prefabs) to the Camera Target of your script.

Here's a screenshot how this looks like (added a Cube GameObject as the camera target):

This feature is not limited to Game-Objects. You can use it for almost any type, eg. use an int for hitpoints, Vector3 for velocity, etc. It's a really powerful concept and you should use it (you can also modify these values on the fly while running your game in the editor to test/tweak your game).