can someone tell me how i can turn this variable “bolaPrefab” in Global?
GameObject bolaPrefab = (GameObject)Instantiate(bolaDoJogo, DirecaoBola.transform.position, DirecaoBola.transform.rotation);
can someone tell me how i can turn this variable “bolaPrefab” in Global?
GameObject bolaPrefab = (GameObject)Instantiate(bolaDoJogo, DirecaoBola.transform.position, DirecaoBola.transform.rotation);
// Outside of function/method
GameObject bolaPrefab;
// In function/method
bolaPrefab = Instantiate(bolaDoJogo, DirecaoBola.transform.position, DirecaoBola.transform.rotation) as GameObject;
if you mean global for your class just declare it outside any method, if you mean global for all classes, declare it outside any method with proteccion level static public
public class Example{
public static GameObject bolaPrefab;
}
//////////////////////////////////////
public class MainClass{
public void exampleMethod(){
bolaPrefab = Instantiate( bolaDoJogo, DirecaoBola.transform.position, DirecaoBola.transform.rotation);
}
}