Game Development Reference
In-Depth Information
Tip
The good thing about generic functions is that it will return the correct type and the
JavaScript code doesn't need to find the correct type when it compiles, which will make
our code faster.
For the C# user, generic functions can help us save time to cast it to the correct type, as
shown in the following script:
Transform t = go.GetComponent<Transform>();
We can use a generic function instead of using the following methods:
Transform t = (Transform)
go.GetComponent(typeof(Transform));
Transform t = go.GetComponent(typeof(Transform)) as
Transform;
We can see that it's a lot shorter.
Note
For more details, visit
http://docs.unity3d.com/Documentation/Manual/GenericFunc-
Gizmos
We've used the
OnDrawGizmos()
function to create the visual viewable for the waypo-
int game object, which will show only in the editor and we won't see anything during the
game play in the
Game
view or in the real game after we build it.
However, if we want to see it while we are playing the game in the
Game
view, we can
click on the
Play
button and click on the
Gizmos
button on the top-right to toggle the giz-
mos on or off, as shown in the following screenshot: