Hello everyone !
Let me introduce my problem to you , so i have script called “MonaBotBaby.cs” in my game. I am trying to get all objects in scene that has “MonaBotBaby.cs” attached.
Well , i don’t want to get only monabots i also want get other enemies and i created a simple function for this task like this ;
public static GameObject[] GetSameTypeObjectsInScene( System.Type objType )
{
GameObject[] objs = GameObject.FindObjectsOfType( objType ) as GameObject[];
return ( objs );
}
Simply it tries to get all object with given type and returns them as game object.
And i am trying to use that function in my other file called “EnemyManager.cs” like this ;
private void GetMonabotsInScene()
{
GameObject[] monabots = ObjectManager.GetSameTypeObjectsInScene( typeof( MonaBotBaby ) );
}
But it is not working , it’s always says null array , reference and yes i am calling this function on Start() callback.
Any help is great , thanks