I'm experimenting with networking in Unity and I can't seem to get an ArrayList of GameObjects to sync from the server to the client.
Here is the relevant code:
[SyncVar]
ArrayList walls = new ArrayList();
void Start ()
{
grid = new bool[width, height];
if(isServer)
{
// This is an algorithm to generate a Maze.
// It adds the walls of the maze (GameObjects)
// to the walls array as the algorithm runs.
CarvePassagesFrom(0, 0, south, grid);
}
// If this instance of the game isn't the server, we want to get the
// already generated maze from the walls ArrayList (that should have synced)
else
{
foreach (GameObject go in walls)
{
Debug.Log("Creating game object: " + go);
Instantiate(go);
}
}
}
I have the console tell me how many walls were added in total after the algorithm has run and the walls have definitely been added. But on the client the size of the walls array is 0.
Am I missing something really obvious about the syncing of variables?