- Home /
Improving code performance
Hi! I have one quastion about how Unity is executing the code.
For example I have such a piece of code:
void Update ()
{
someAnim.speed = 2;
someBool = true;
someInt = 5;
}
and Update() is called every frame. Are these operations executed every frame or Unity understands that there is no need to set the same value to some variable many times per second?
Should I optimize this piece of code or is it done automatically?
Thanks!
Answer by perchik · Apr 01, 2014 at 06:52 PM
Those operations are executed each frame. If you need it done once, do it in Start()
I change them sometimes but, of course, not every frame. Thanks, I'll workout some code optimizations!
Your answer
Follow this Question
Related Questions
How performant is performant? 0 Answers
How can I optimize this code? 2 Answers
Merging together all GameObjects of an Array? 1 Answer
Sprite Alpha Performance 0 Answers
compiler problem 1 Answer