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.