system
1
Ive got an error:
Cannot cast from source type to destination type.
when I try to use foreach in other script:
bInfo = gameCore.GetComponent<bInfo>();
ArrayList boyList= bInfo.boyList;
foreach (PlayerNode entry in boyList){}
The list contains of:
public class PlayerNode
{
public string name;
public string id;
}
Generally you can extract elements from a collection of types using Linq.
Let’s say you have a collection that contains many different things and you just want the list of the ones that are PlayerNodes:
using System.Linq;
...
foreach(var entry in bInfo.boyList.OfType<PlayerNode>())
{
}
I’m not 100% sure that this is your problem as I can’t see the definition of boyList inside the bInfo script.