Hello, I’m sorry I don’t quite know how to do code snippets here. I have two scripts, a general sort of one which manages an array list and then a second which I wish to access the array list from.
So in the manager script (called PlayerManager) I have:
public ArrayList playerList = new ArrayList();
public class PlayerEntry
{
public string name;
public NetworkPlayer player;
}
Then in my other script I wish to access this array list and add new entries. The following commands attempt to create a new entry to this array list.
PlayerManager.PlayerEntry newEntry = new PlayerManager.PlayerEntry();
newEntry.name = playerName;
newEntry.player = Network.player;
PlayerManager.playerList.Add(newEntry);
The first command works where the program is able to create the temporary entry. However, the error appears to be on the final line where I actually attempt to access the list itself.
The error code itself is:
error CS0120: An object reference is required to access non-static member `PlayerManager.playerList'
The unity script reference implies that this is how you access global variables from another function with script.variable. Does anyone know what I am doing wrong?