Hi to all!
Optimizing my touch controller script, and wondering about the following example in the docs (comments removed, stripped down to essentials) :
function Update () {
for (var i = 0; i < Input.touchCount; ++i) {
if (Input.GetTouch(i).phase == TouchPhase.Began) {
var ray = Camera.main.ScreenPointToRay (Input.GetTouch(i).position);
}
}
}
Is there no overhead involved in repeatedly calling GetTouch(i), instead of caching the Touch object at the beginning of every iteration? I followed this model, and call GetTouch a bunch of times in my TouchController script. Just to make sure I’m clear, would this be better, performance wise:
myTouches = new Touch[maxTouches];
function Update () {
for (var i = 0; i < Input.touchCount; ++i) {
myTouches*=Input.GetTouch(i);*
if (myTouches(i).phase == TouchPhase.Began) {
var ray = Camera.main.ScreenPointToRay (myTouches(i).position);
}
}
}
Thanks for your insights!