Hi everyone, I have a question about performance and instances. I always see in Unity tutorials, that the trainers or tutors, preffer to make local instances, each frame, or each interation, such as in Update, instead of make a allocated global variable (“global” means that it isn’t a variable of a method, it is a class field).
So, my question is about it and performance, I mean, it is bad for performance make instances all the time, instead of make a “cached” variable, that you will do the instance once? Usually, I always make “global” variables, with just one instance, every time the class is instantiated (Again, ‘global’ means that it is a field of a class, and not a local variable of a method), be in MonoBehaviours or Editor stuff.
And of course, it is not only about processing, but about memory too.
So, which would be better for performance?
(Sorry about my english, hope you can understand :D)