Is there a way to GetComponent() with space in its name? (using #pragma strict)

Hi,

I’m going through this tutorial http://vimeo.com/19463171 and it instructed me before to create assets with space in their names. Now there is code like this:

other.GetComponent("script player").lives -= 1;

I am trying to write my scripts with #pragma strict declaration so I need to cast Component to proper script type before I can access lives field. The problem is that I cannot guess what is the type name of this script.

  • I know that I could rename (and I did) the script to playerScript and then use its type name playerScript instead of string.
  • I know that using GetComponent(String) is not recommended.
  • I am curious what type name will script called script player will have if any (how to find it out?)
  • And I am curious if GetComponent(String) is usable when using #pragma strict.

TIA

You cannot have a space in the name because no class can have a space in its name. The assets you have created are not accessed using GetComponent (that accesses scripts) - rather you would find them using transform.Find and/or GameObject.Find