Getting Prefabs gameobjects with tags from folder

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

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;
    Map[list.Count()] = GetComponent<GameObject>();
    foreach (var item in list)
            Map[i] = item;


Related Questions

Checking if object passed between two other objects

Updated April 14, 2015 20:05 PM

Unity C# 2D Platformer Enemy Patrolling

Updated April 03, 2015 21:22 PM

Material not changing Unity3d

Updated June 04, 2015 12:05 PM