Static or GetComponent Cashe

I am just wondering if there is any difference in a static variable and a cashed component. I have options that I wanted to leave on one script and access throughout the game like sound, vibration, ect… and did not want to rewrite them in every script so I made them all static and then started wondering if thats bad for performance. I am writing for Android and am trying to get all I can out of it.

//OPTIONS SCRIPT
static var useSound : boolean;

function Start(){
     useSound = PlayerPrefsX.GetBool(playerName+" sound");
}
//GAME SCRIPT

var explode : boolean;
var explodeSound : AudioClip;

function Update(){
     if(explode  OptionsScript.useSound){
          audio.PlayOneShot(explodeSound);
     }
}

or is this better?

//GAME SCRIPT CASHE

var options : OptionsScript;
var explode : boolean;
var explodeSound : AudioClip;

function Start(){
     options = GetComponent(OptionsScript);
}

function Update(){
     if(explode  options.useSound){
          audio.PlayOneShot(explodeSound);
     }
}

Or is this a waste of time and 6 of one 1/2 dozen of another.

It’s not a question of performance, it’s a question of behavior. A static variable means there’s only one instance of it in that class. You should only use static variables if you specifically want this to happen, otherwise use GetComponent.

–Eric

Sorry but I need to clarify here, say it is for options and you want to access it anywhere in the game and only have one instance of class then use static, but if its hit points on a enemy and each has its own class use getcomponent so each can have their own hitpoints. Hope I am understanding this. Thanks!