List some how being edited indirectly

I was trying to debug some code that was referencing a list called levelGenerator.placedFloors and found that the count was being modified. I’ve figured out that for some reason the line “GameManager.instance.spawnPoints.RemoveAt(randInt);” is doing it. No where, in any script is placedFloors being set to the spawnPoints. But each time this while loops one element is removed from both GameManager.instance.spawnPoints and levelGenerator.placedFloors. Does anyone know what might be going on?

                        GameManager.instance.spawnPoints = levelGenerator.placedFloors;
                        while (i <= enemiesToSpawn)
                        {
                            //Random spawnpoint
                            randInt = Random.Range(0, GameManager.instance.spawnPoints.Count);
        
                            //Instantiate enemy.
                            randEnemyType = Random.Range(0, enemyPrefabs.Count);
                            instanceGO = Instantiate(enemyPrefabs[randEnemyType], GameManager.instance.spawnPoints[randInt].transform.position, Quaternion.identity) as GameObject;
        
                            //Cache enemy
                            GameManager.instance.AddEnemy(instanceGO);
        
                            //Remove used spawn point.
                            print("LevelGen placedFloors " + levelGenerator.placedFloors.Count);//Debug
                            GameManager.instance.spawnPoints.RemoveAt(randInt);
                            print("LevelGen placedFloors " + levelGenerator.placedFloors.Count);//Debug
        
                            i++;
                        }

On the first line of your code your setting the reference of GameManager.instance.spawnPoints to levelGenerator.placedFloors.

If you want to copy the list use

GameManager.instance.spawnPoints = new List<T>(levelGenerator.placedFloors);

No where, in any script is placedFloors being set to the spawnPoints.

GameManager.instance.spawnPoints = levelGenerator.placedFloors;

When it comes to object references… there is no difference.