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

[SyncVar] crashes Unity??

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

  1. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    120
    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:
    120
    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:
    291