Lads,
Do you always have to have ‘function Update()’ or some derivitive of it present in your scripts?.. I have written scripts that do not have ‘function Update ()’ present that seem to work alright…
Stef
Lads,
Do you always have to have ‘function Update()’ or some derivitive of it present in your scripts?.. I have written scripts that do not have ‘function Update ()’ present that seem to work alright…
Stef
No, it isn’t needed at all! When you create a new script, it gives you the outlines for ‘Update’ and ‘Start’, because these are the most commonly required functions, but if your specific script doesn’t have any use for them, feel free to delete them!
Removing Update from your script will actually make your code marginally faster, since it doesn’t have to call an empty function every frame. Another thing you may notice, is the ‘enabled’ checkbox on your component will disappear! This is because what that checkbox basically does is activate the various update calls on your script, so if it doesn’t have any of those there’s no point using it.
No, you don’t have to. Acutally you shouldn’t even put a function Update in if you don’t need it. Unity will recognise that and exclude this script from the Update cycle which could increase your over all performance a little bit (mostly not noticeable but, hey).