I’m trying to do an Real TIme Strategy game for a school project, having gone in a bit over my head i am now stuck at the very basics of the game not fully understanding how to do things in unity. I’ve gotten the selecting multiple aswell as deselecting working. The problem comes when i want to save the selected units into another list (a control group) by pressing A + a number between 1-9 and storing it in a list that corresponds to that number. After doing a few tests it seems like it does not properly save in the list after completing the code in the if statement.
To explain why i think that, even though it could be something else, look at the picture of the console log.When i select 3 units and then press a + 1 the Selectedunits list gets stored in Controlgroups[1] and then outputs to the log Controlgroups[1].count, and it outputs 3 like it should. But when i only press 1 it should tell me the length of the list in controlgroups[1] which should be 3 but is instead 0, then it should deselect all selected units, copy the list from Controlgroup[1] into Selectedunits and select them. This does not happen and i don’t know why. Instead the first time i press 1 it just deselects everything and does not go through any of my debug.log and the second time it says that controlgroups[1] is empty.