Sorry if the title sounds confusing i try my best to explain my situation:
I have a empty gameObject in the scene called “managers”, it have a script that have many Public GameObjects which are prefabs that i dragged and dropped in the editor.
I’m doing this so i can organise all the prefabs in one place, and to instantiate them from another script i can just use GameObject object = managers.GetComponent ().oneOfTheGameObject;
and then instantiate it like so: GameObject.Instantiate (object, pos, rot);
But for some reason the line: GameObject object = managers.GetComponent ().oneOfTheGameObject; gives me null reference error.
The error line is being called on void start() on another script, which the manager is linked by
void Awake(){
managers = GameObject.FindGameObjectWithTag(“managers”);
}
So in summary, the prefab should exist on the manager’s script as a GameObject(dragged and dropped in editor), but when i try to access this object from another script it gives me null error.
Im new to unity, if there’s a better way of what im trying to do, please let me know.
Thanks very much!