Hi I had a problem with the list, I spent two days and solved it, but I want to understand what it was.
I have a private List “Vector3” in my Player script and another private List “Vector3” in the Level Script. When the game starts, the Player List is updated correctly, but then I update the Player List from the Level Script by calling the function:
void SetWaypoints()
{
Player.SetWaypoints(Level_List);
}
public void SetWaypoints(List<Vector3> list)
{
Player_List = list;
}
My player list is updated and after that the player list remains clean.
My function adds vectors to the player list, but the player list remains clean.
I don’t call any other list cleaners and this function is no longer called.
When I figured out the problem, I wrote this function and all the problems went away.
public void SetWaypoints(List<Vector3> list)
{
Player_List.Clear();
for(int i = 0;i<list.Count;i++)
{
Player_List.Add(list*);*
}
}
Finally, the question is: Why does the list work this way? Is this a bug?
Unity version: 2019.2.18f1