Missing parameter for call to GetComponent

Hey,

I have just noticed that wordpress is removing some of the code from my source code … I know that some helpful people have pointed this out a couple of times already, but this is the first time I have had a serious look. My apologies for all of the trouble this has caused people (mainly due to compile errors you would have got). Every time GetComponent() is called it is expecting a type being passed in angle brackets. For example

WorldObject worldObject = hitObject.transform.root.GetComponent< WorldObject >();

rather than

WorldObject worldObject = hitObject.transform.root.GetComponent();

which is how all of the code published in the blog so far has come out as. The type to be passed in is the type that you are saving the object as. So in the example above we are storing a WorldObject, so we need to put WorldObject between the angle brackets. I will go through all of the posts in the near future and tidy this up so that in the future people do not have this problem.

Edit: It seems that this may not even be consistent … Note to anyone trying to comment with corrections, it seems to need spaces between the angle brackets and the type in order to show more consistently.

Advertisements

2 thoughts on “Missing parameter for call to GetComponent

  1. Well – its a good way to keep people on their toes 😀
    Also – welcome back dude! you have been missed – now I just need to find some free time so i can read the new stuff… been looking forward to this 🙂

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