Search Unity

SyncListChanged only gets called on client, can call on server?

Discussion in 'Multiplayer' started by tinman, Mar 29, 2016.

  1. tinman

    tinman

    Joined:
    Jan 8, 2011
    Posts:
    229
    I have a SyncListStruct and with a callback. The callback is however only called on the client, never on the server. I understand that maybe by definition it is meant to be called on the client only, but I was wondering if there is a way to call it on the server too.

    //defined playerDatalist...

    public override void OnStartClient()
    {
    playerDataList.Callback = OnSyncListStructChanged;
    }
    public override void OnStartServer()
    {
    playerDataList.Callback = OnSyncListStructChanged;
    }
     
  2. srylain

    srylain

    Joined:
    Sep 5, 2013
    Posts:
    159
    SyncListStructs will only sync to the clients naturally if they are changed on the server I believe. So if you are trying to modify it on a client, it won't send the change to the server and the server won't update all the clients.
     
  3. tinman

    tinman

    Joined:
    Jan 8, 2011
    Posts:
    229
    Thanks but I am not trying to modify it from client to server. I just want that when the server changes the list, the callback is called on the server as well.
     
  4. srylain

    srylain

    Joined:
    Sep 5, 2013
    Posts:
    159
    I've got no idea then, as it works just fine for me. I have heard about a bug that will make SyncListStructs not work because of the name of the file they're in, so maybe try changing the name of the file a few times to see if that could be it?
     
  5. tinman

    tinman

    Joined:
    Jan 8, 2011
    Posts:
    229
    I just want the callback to be calledon the server when the SyncList is changed :)
     
  6. srylain

    srylain

    Joined:
    Sep 5, 2013
    Posts:
    159
    Only the server is able to change a SyncListStruct normally, so that should be easy enough to just add another function call in the function you have that changes it.
     
  7. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,264
    Sure. But knowing how to workaround that is not the ultimate issue here... If OnStartServer listens to a callback, I expect it to be invoked. Did you file a bug via the bug reporter @tinman so I can vote on it?