I basically want to make a public static gameObject but it doesnt show it in the inspector.How can I assign the gameobject I want then?
CodePudding user response:
You cannot do that. Firstly, static classes cannot inherit anything and in Unity3d, only classes who inherits GameObject
class are addable.
CodePudding user response:
Static cannot be shown in component instance because it is "above" the component, it belongs to the class type and there is only one shared by all components of this type.
Your solution could be to find the game object and then assign it to the static variable.
public static GameObject TheStaticGO {get; private set;}
void Start()
{
// Only assign if empty
if(TheStaticGO == null){
TheStaticGo = GameObject.Find("StaticGOName");
}
}