Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

[SyncVar] crashes Unity??

Discussion in 'Multiplayer' started by Royall, Jul 19, 2015.

  1. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    123
    When I use SyncVar on a class array, Unity crashes:

    Code (CSharp):
    1. [System.Serializable]
    2.     public class Inventory {
    3.         public int id;
    4.         public int amount;
    5.     }
    6. [SyncVar] public Inventory[] inventory;
    Anyone knows whats wrong or how to fix this?
     
  2. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    123
    Looks like they fixed the crash in 5.1.2, syncvar on a class array doesnt work though. Get this error:

    UNetWeaver error: SyncVar [PlayerController/Inventory[] PlayerController::inventory] cannot be an array. Use a SyncList instead.

    Anyone know how to use SyncList?
     
  3. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    293