Get unity to recognize prefab in C#

Hi. This seems like it should be pretty basic. I have a prefab called Grapple_Arrow. It contains meshes and scripts. I want to instantiate one of these when I hit a key, lets say. According to documentation I should do something like:

public class example : MonoBehaviour {
 public Missile projectile;
 void Update() {
  if (Input.GetButtonDown("Fire1")) {
   Missile clone;
   clone = Instantiate(projectile, transform.position, transform.rotation);
   clone.timeoutDestructor = 5;

Except that if I do exactly that with my prefab, I get an error:

error CS0246: The type or namespace name `Grapple_Arrow' could not be found. Are you missing a using directive or an assembly reference?

What I can do is this (feels like a workaround):

public class LerpzGrapple : MonoBehaviour {
public GameObject theGrapple;
// Use this for initialization
void Start () {
// Update is called once per frame
void Update () {
    // later change this to getButtonDown
    if (Input.GetKeyDown(KeyCode.Return)) {
        GameObject grapple = Instantiate(theGrapple, transform.position, transform.rotation) as GameObject;
        //grapple.OriginatingObject = gameObject;
        Grapple grappleScript = grapple.GetComponent("Grapple") as Grapple;
        grappleScript.originatingObject = gameObject;


And lo, it actually instantiates an object (actually I just figured this part out while typing the question). But it seems kind of a roundabout way. Can't I just add a line "using MyPrefab" or #include MyPrefab or something?

As it is, I can only instantiate a generic GameObject (which I even have to cast from Object to GameObject?!) when it seems I could have access to the exact prefab and all its many scripts and properties. (That's how it would be if I was working in pure code anyway.) From my generic GameObject, to access a property I have to do GetComponent()... which, while I don't know how it actually works, it looks like it's doing a string comparison. I hope that's in the precompile stage only. :)

So the crux of my long-winded question here is:

  1. am I doing this right?
  2. Is any part of my code redundant or suboptimal?
  3. Is there an easier / better way (in C#) ?

Your "workaround" is generally how it's done, except you can combine all those steps into one. Also you should generally not use strings in GetComponent (see the docs, although in addition to performance, you get compile-time error checking instead of runtime), and using generics is simpler.

(Instantiate(theGrapple, transform.position, transform.rotation) as GameObject).GetComponent<Grapple>().originatingObject = gameObject;

You could shorten it by declaring the prefab like this:

public Grapple theGrapple;

Then you can cast to Grapple when instantiating:

(Instantiate(theGrapple, transform.position, transform.rotation) as Grapple).originatingObject = gameObject;

What type you use depends primarily on what's most convenient to refer to with the instantiated object.

There's nothing really inherently wrong with how you are instantiating/using grapple. I presume that you are getting that error because Grapple_Arrow is a prefab. Prefabs themselves aren't types, they're components or GameObjects, so you can't create a variable who's type is a prefab name.