I'm trying to access a List from another script. It gives me the error in the title. What did I do wrong?
TreeGen.cs
public GameObject Instree;
int trees;
public List<int> TreeCount;
void Start() {
trees = Random.Range(100, 300);
for (int i = 0; i < trees; i++){
{
Instree = Instantiate(tree, position, Quaternion.identity);
TreeCount.Add(Instree.GetInstanceID());
}
}
TreeDestroy.cs
TreeGen treeGen;
void Update(){
for (int i = 0; i < treeGen.TreeCount.Count; i++) {
{
if (treeGen.Instree.GetInstanceID() != treeGen.TreeCount[i])
{
//something to do
}
}
}
}
Note: I know this shouldn't be in Update(), but I want to know if it even works