call public static varable from another script in Update performance

Updated on October 2, 2018 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on October 2, 2018

Hi

 

I want to know doe’s using a public static variable from other scripts in UPDATE() affects on game performance or not ?

 

something like this :

 
void Update()
 
{
 
   if(otherscript.variable == 55)
 
      {
 
         //do something
 
      }
 
}
 

  • Liked by
Reply
0 on October 2, 2018

Theoretically… yes

However, in practice, with everything else being equal, the difference is so negligible, that it doesn’t really matter. Just use static wherever it makes sense, and don’t worry about trying to shoehorn it into to situations it doesn’t need to be/ should not be used in.

 

  • Liked by
Reply
Cancel