When I use SyncVar on a class array, Unity crashes:
[System.Serializable]
public class Inventory {
public int id;
public int amount;
}
[SyncVar] public Inventory[] inventory;
Anyone knows whats wrong or how to fix this?
When I use SyncVar on a class array, Unity crashes:
[System.Serializable]
public class Inventory {
public int id;
public int amount;
}
[SyncVar] public Inventory[] inventory;
Anyone knows whats wrong or how to fix this?
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?
http://docs.unity3d.com/ScriptReference/Networking.SyncList_1.html
You cannot, however, use it with classes. Only primitive types and structs (The link above leads to the SyncList Interface, but there are implementations like SnyListBool or SyncListStruct).