Hi Guys,
I am trying to do a very simple operation, which is adding GameObjects
to a list with a specific tag
, but its not working consistently across play mode. The following piece of code is in a Class which is a script attached to a Prefab.
//List to store Activated PlaceHolders.
base.activatedPlaceHolders = GetActivatedPlaceHolders(base.placeHolderLocalList);
private List<PlaceHolder> GetActivatedPlaceHolders(List<PlaceHolder> placeHolderList)
{
List<PlaceHolder> activatedPlaceHolders = new List<PlaceHolder>();
foreach (var item in placeHolderList)
{
if (item.gameObject.tag != "CollidedPlaceHolder") activatedPlaceHolders.Add(item);
}
return activatedPlaceHolders;
}
The class PlaceHolder
is attached to another Prefab
. What I am trying to do is to add the PlaceHolders whose tag is not “CollidedPlaceHolder” to the activatedPlaceHolders List. But its not working consistently when the game is played and I am not sure why. The main goal is to ignore the place holders with such a tag.
Any help would be very nice!