- Home /
Calling static Class instance variables form another class related to slowdown?
Should I just presume that onGUI is the sin that is causing my lower FPS?
The main question I have is if calling an object from another class (that is static) is expensive.
I.e. is GlobalValues.Players[0].army.Unit[4].body.trans.... etc etc much more expensive than players[0].army.Unit[4].body.trans...
Should I just have an instance of the GlobalValues player object class array? Or is the processing cost negligible?
..Something tells me onGUI is going to win the blame either way.
Answer by cagezero · Apr 30, 2013 at 12:35 AM
Static method calls vs instance method calls are almost identical as far as CPU cycles are concerned. Worrying about the difference is certainly not worth your time at this point.
OnGUI is infinitely more likely to be the cause of any slow down you might be experiencing when compared to static vs instance access.