Convert 2d array to list.
I created a lot of code for a tower defense game that uses a 2D Array for the nodes [x, y]. After getting really far into it and creating a rather large pathfinding system that frequently uses array commands, I realized I will need to remove objects from it (Woops) , so I need to convert it into a list. The problem is that when I try to use the following code.
System.Collections.Generic.List<GameObject> gridList = new System.Collections.Generic.List<GameObject>(grid.gridArray);
It throws "Argument 1: cannot convert from 'UnityEngine.GameObject[*,*]' to 'System.Collections.Generic.IEnumerable< UnityEngine.GameObject>'"
I'm assuming this is because 2d lists don't exist? if so, is there a way to remove objects from a 2D array? #WishfulThinking
Answer by zerossoul · Jun 09, 2020 at 06:21 PM
I just thought outside the box and figured out a much cleaner solution. Instead of removing a node, I'm telling my script to ignore it if it has a bool ignore = true.
Your answer
