Hey guys !
Trying to make a cookie -clicker-like game and I’m having troubles accessing variables between scripts.
Here is the deal :
- In one script, I have a public non-static variable of type int.
- I need to access it from another script that is in the same gameobject.
- The gameobject containing the scripts aforementioned comes from a Prefab, so many objects will share those scripts and I can’t use a static variable.
- I tried using a reference but I couldn’t do anything to the variable because of its type…
So here is my first script :
public class Achat : MonoBehaviour {
public int NombreUnité;
}
And I need to use that variable in another script of the same object, without refering to that gameobject’s name…
Maybe I can’t find the solution just because I’ve been working on it the whole afternoon… anyway if someone could help that would be nice.
Clap