i made something like this: storage = new storageclass();
storageclass is class with variables but this wont work. I expect to use class to diffrent scripts and each script will have the same name to variables but other value.
create a static class , so all GameObject’s scripts, can use this script by “storageclass.variable”. Or, in a script just do :
public class storageclass : MonoBehaviour {
//variables
}
public class FirstScript : MonoBehaviour {
storageclass storage;
void Start() {
storage = GameObject.GetComponent<storageclass>();
}
}
public class SecondScript : MonoBehaviour {
FirstScript firstScript;
void Start() {
firstScript = GetComponent<FirstScript>();
storageclass storage = firstScript.GetComponent<storageclass>();
}
}