What does it mean when the documentation refers to whether something “does not allocate temporary variables” vs “allocates temporary variables”
http://unity3d.com/support/documentation/ScriptReference/Input.html
What does it mean when the documentation refers to whether something “does not allocate temporary variables” vs “allocates temporary variables”
http://unity3d.com/support/documentation/ScriptReference/Input.html
Well, they refer to the fact that the [touches][1] and [accelerationEvents][2] properties of Input create an array out of the individual Touches. Here’s how .touches is implemented internally:
// C#
public static Touch[] touches
{
get
{
int touchCount = Input.touchCount;
Touch[] array = new Touch[touchCount];
for (int i = 0; i < touchCount; i++)
{
array *= Input.GetTouch(i);*
}
return array;
}
}
It’s just a hint that it might be a performance overhead if you use this property multiple times each frame. If you just need the information of one specific touch you should use the GetTouch() method instead.
[1]: http://unity3d.com/support/documentation/ScriptReference/Input-touches.html
[2]: http://unity3d.com/support/documentation/ScriptReference/Input-accelerationEvents.html