|
If I have a GameObject with three scripts attached to it, do all three scripts have to have an Update() function? Can 1, 2 or even all 3 have no Update() at all but just normal called functions, maybe that are called by another script attached to another GameObject? And if so, does it make any difference? I read somewhere on another forum that for iPhone optimisation, it's better to have one function to affect a whole collection of objects, rather than each of those objects having its own little Update()...
(comments are locked)
|
|
No, none of the scripts on your GameObject have to include an Update() function. The memory cost for ten Update()'s is really affected by what you do in it. Alone, it's minimal, so I wouldn't worry about it. I see. Does an empty Update() function actually cost some performance? Over and above a script with lots of called functions but no Update() function? (if I had thousands of instances, for example)
Feb 03 '11 at 10:25 PM
robinking
An empty Update() function costs next to nothing, because you're not doing anything to use up memory in it. Even if you did have thousands of instances, the memory use is still tiny and not worth worrying about. ;)
Feb 03 '11 at 10:28 PM
e.bonneville
That's not really true; an Update call does have overhead, and should be removed if you're not using it. Thousands of objects with empty Update functions will have a noticeable performance hit an an iPhone (not that you'd want thousands of objects on an iPhone to begin with).
Feb 03 '11 at 11:06 PM
Eric5h5
Cool, thanks for the info!
Feb 04 '11 at 12:12 AM
robinking
Thanks for clearing that up, Eric. I've not worked with iPhone before, so my experience is solely with high-end platforms. As a result, I don't know a whole lot about iPhone optimization.
Feb 04 '11 at 12:33 AM
e.bonneville
(comments are locked)
|
