Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party How to pass SyncLists from a script to another? (in Mirror)

Discussion in 'Multiplayer' started by jiexdrop, Jan 20, 2021.

  1. jiexdrop

    jiexdrop

    Joined:
    Oct 24, 2019
    Posts:
    7
    I have a problem with SyncLists. I can't set them when I spawn a gameObject from the server to the clients. Here is how I set the lists and spawn the game objects: https://hatebin.com/sngqqkomiz
    Here is how I try to access them: https://hatebin.com/ervomvzpvf
    I'm having a null reference exception, because the list is not set.

    I tried setting a string the same way and it does work. The right string is set on the server and is passed to the client and it is the same string. What am I doing wrong ?

    What I'm trying to do is to pass a syncList from an object to another as a reference.

    What I've checked:
    • The SyncList is on a networkbehaviour
    • The Synclist is only updated and set from the server side
    • I'm sending a ScriptableObject with a single string (It's a data type suported by Mirror)
    My error is I can't pass SyncLists to other objects as a reference. But I can pass any other SyncVar.

    Using simple C# lists (List<Item>()) does not work because they don't update from the server to the clients when they are changed in the server.
     
    Last edited: Jan 21, 2021