Search Unity

Which is the fastest method: global var or get component

Discussion in 'Scripting' started by xandeck, Aug 20, 2009.

  1. xandeck

    xandeck

    Joined:
    Apr 2, 2009
    Posts:
    563
    Please,

    I have a doubt about speed and optimization in my script.

    I'm currently using a global var (static var) to point some data into another script. But also I tried to use the GetComponent (or other method to acess functions from diferents scripts).

    Which is the fastest? Supose that I have hundreds of line code and models in my screen... I need to let the game run the best possible (of course)...

    Thanks for the help
     
  2. jaxas

    jaxas

    Joined:
    Mar 22, 2009
    Posts:
    59
    i thing global var, cause it saves info, and you just get it, and no need to call functions etc :)
     
  3. xandeck

    xandeck

    Joined:
    Apr 2, 2009
    Posts:
    563
    Hmm... yeah, maybe :)

    Thanks for the reply