Getting Prefabs gameobjects with tags from folder

by Elenor   Last Updated June 11, 2019 23:13 PM

I have some problems. When I refreshedd codes or tags on projects. This code does not work. When I rechoose tags again on prefabs, it starts to work again.

"Map[list.Count()] = GetComponent<GameObject>();" 

In this piece of code is not working I did not understand why? I'm using this code because when I created new map,everytime I don't want to add it.

void Start()
{
    var list = Resources.FindObjectsOfTypeAll(typeof(GameObject)).Cast<GameObject>().Where(g => g.tag == "Map").ToList();
    var i = 0;
    Debug.Log(list.ToList());
    Map[list.Count()] = GetComponent<GameObject>();
    foreach (var item in list)
    {
            Debug.Log(item);
            Map[i] = item;
            i++;
    }


}


Related Questions


Updated April 14, 2015 20:05 PM

Updated May 13, 2015 12:43 PM

Updated April 03, 2015 21:22 PM

Updated June 04, 2015 12:05 PM

Updated June 04, 2015 14:05 PM