public static BuSCRIPTInADI instance;
private void Awake()
{
CreateInstance();
}
void CreateInstance()
{
if (instance == null) { instance = this; }
else { Destroy(gameObject); }
}
Şimdi diğer scrite girip aşağıdaki kod ile tüm değişkenlere erişebilir değiştirebiliriz :)
BuSCRIPTInADI.instance. noktadan sonra o scriptteki public olarak tanımladığımız değişkenler görünecektir.
private void Awake()
{
CreateInstance();
}
void CreateInstance()
{
if (instance == null) { instance = this; }
else { Destroy(gameObject); }
}
Örnek:
BuSCRIPTInADI.instance.can = 100;
BuSCRIPTInADI.instance.can = 100;
0 Yorumlar