Update with transform

Tip This code could be optimized further by using object caching for the Transform Component.
The basic idea is that on each Update call, the code relies on the transform property, such as
transform.position.x, and so on. Each mention of this property, in that way, entails a further call internally
to GetComponent<Transform>(). To avoid this overhead we can use the Start event to get or cache a
reference to the Transform Component with a one-off call to Transform MyTransform = transform.
Then in all subsequent calls to the Transform Component, we use the cached version MyTransform, as
opposed to transform. In the code samples here, however, I use transform for simplicity and brevity.

posted @ 2014-05-14 22:10  penney  阅读(113)  评论(0)    收藏  举报