Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Unity Multiplayer [SyncVar] crashes Unity??

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

  1. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    118
    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:
    118
    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:
    286