Getting object type in Unity3D/Javascript

for archive sake really:

Debug.Log(“Type of object: ” + gameObjectCopy_1.GetType().Name);

Can be used in a conditional like so:

if( gameObjectCopy.GetType() == GameObject) // do something

prints out what the immediate class type is of the object.

  1. First hit on Google for me. Thanks for taking the time to write this down. Am I the only one who has trouble finding things on the Unity docs site?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s