Search Unity

access other scripts with static

Discussion in 'Scripting' started by mattcscz, Nov 8, 2010.

  1. mattcscz

    mattcscz

    Joined:
    Mar 7, 2010
    Posts:
    411
    hey guys, i've started using playerprefs and want to know if theres a better way to access another scripts var without using the static function? both the scripts are in diffent scenes too btw
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Static variables are often the easiest way to go about this but it depends on what you need to do. They allow data to be shared between scenes but they don't store the data persistently like PlayerPrefs.
     
  3. Chris-Sinclair

    Chris-Sinclair

    Joined:
    Jun 14, 2010
    Posts:
    1,326