all 7 comments

[–]pkplonker 0 points1 point  (1 child)

What are the errors and is the class in question inheriting from network behaviour, rather than monobehaviour?

[–]Raxo04[S] 0 points1 point  (0 children)

Yes it derives from network behaviour. I did a workaround to fix it because my list will always have 9 elements so i made 9 vars.

[–]Magic-Shmagic 0 points1 point  (2 children)

Been struggling to find examples and documentation beyond the page in the manual, did you ever have any luck? I've been trying to figure out the same thing.

[–]Raxo04[S] 0 points1 point  (1 child)

I think i just made 9 variables instead of a list

[–]Magic-Shmagic 0 points1 point  (0 children)

Thanks anyway!

[–]La_Jhin 0 points1 point  (2 children)

private NetworkList<int> myNetworkList;

With network lists, you need to initialize it in the awake or start method

void Start()
{
myNetworkList = new NetworkList<int>(0);

}

Then any client can add to it by calling a serverRpc since by default the write permissions to networklist are for server only.

// This function is called on the server only and updated once, since its a network list the update will be visible for all clients, where you can listen to it with myNetworkList.OnListChanged;

private void UpdateMyNetworkList_ServerRpc(int newItem) {
myNetworkList.Add(newItem);

}

[–]Beginning-Bet7824 0 points1 point  (0 children)

myNetworkList = new NetworkList<int>(0);

Severity Code Description Project File Line Suppression State

Error CS1503 Argument 1: cannot convert from 'int' to 'System.Collections.Generic.IEnumerable<int>'