Static variables heavy for the iphone's CPU?

I use static variables quite a lot. I have a basic movement script for my main character and have lots of static vars (ok at the moment they are 8, I actually don't know if this is "lots") in it. The behavior of the other objects depends a lot on these static variables.

I was wondering if this is heavy for the iphone's cpu, as the device will have to switch from reading the various object's scripts to reading the static variables value from my basic script.

If its 8 variables, I dont think you will be able to notice nor benchmark the difference. If you have a tilemap of 1024x1024 blocks in a global array perhaps. I dont know enough about how unity handles "statics".

Another thing is also to think of how often do you read/write to these variables? once a minute or everyframe?

Sometimes statics are both easier and faster than using functions to access the same variables.

My guess would be its faster this way at the moment, but without insight in your actual code, its hard to tell.

The fact that your variables are static won’t make any difference. None.

Accessing variables through a function incurs the penalty of a function call. So in the simplest case direct access to the variable will be faster.

The fact that your variables are static won’t make any difference. None.

Accessing variables through a function incurs the penalty of a function call. So in the simplest case direct access to the variable will be faster.