Class SyncList<T>
This is the base class for type-specific SyncList classes.
A SyncList can only be of the following type;
- Basic type (byte, int, float, string, UInt64, etc)
- Built-in Unity math type (Vector3, Quaternion, etc),
- NetworkIdentity
- NetworkInstanceId
- NetworkHash128
- GameObject with a NetworkIdentity component attached.
Namespace: UnityEngine.Networking
Syntax
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public abstract class SyncList<T> : IList<T>, ICollection<T>, IEnumerable<T>, IEnumerableType Parameters
| Name | Description | 
|---|---|
| T | 
Properties
Callback
The delegate type used for SyncListChanged.
Declaration
public SyncList<T>.SyncListChanged Callback { get; set; }Property Value
| Type | Description | 
|---|---|
| SyncList.SyncListChanged<> | 
Count
Declaration
public int Count { get; }Property Value
| Type | Description | 
|---|---|
| Int32 | 
IsReadOnly
Declaration
public bool IsReadOnly { get; }Property Value
| Type | Description | 
|---|---|
| Boolean | 
Item[Int32]
Declaration
public T this[int i] { get; set; }Parameters
| Type | Name | Description | 
|---|---|---|
| Int32 | i | 
Property Value
| Type | Description | 
|---|---|
| T | 
Methods
Add(T)
Same as List:Add() but the item is added on clients.
Declaration
public void Add(T item)Parameters
| Type | Name | Description | 
|---|---|---|
| T | item | Item to add. | 
Clear()
Same as List:Clear() but the list is cleared on clients.
Declaration
public void Clear()Contains(T)
Determines whether the list contains item item.
Declaration
public bool Contains(T item)Parameters
| Type | Name | Description | 
|---|---|---|
| T | item | Item to search for. | 
Returns
| Type | Description | 
|---|---|
| Boolean | True if item contain | 
CopyTo(T[], Int32)
Declaration
public void CopyTo(T[] array, int index)Parameters
| Type | Name | Description | 
|---|---|---|
| T[] | array | |
| Int32 | index | 
DeserializeItem(NetworkReader)
This method is used when deserializing SyncList items from a stream.
Declaration
protected abstract T DeserializeItem(NetworkReader reader)Parameters
| Type | Name | Description | 
|---|---|---|
| NetworkReader | reader | Stream to read from. | 
Returns
| Type | Description | 
|---|---|
| T | New instance of the SyncList value type. | 
Dirty(Int32)
Marks an item in the list as dirty, so it will be updated on clients.
Declaration
public void Dirty(int index)Parameters
| Type | Name | Description | 
|---|---|---|
| Int32 | index | Index of item to dirty. | 
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()Returns
| Type | Description | 
|---|---|
| IEnumerator<T> | 
HandleMsg(NetworkReader)
Declaration
public void HandleMsg(NetworkReader reader)Parameters
| Type | Name | Description | 
|---|---|---|
| NetworkReader | reader | 
IndexOf(T)
Declaration
public int IndexOf(T item)Parameters
| Type | Name | Description | 
|---|---|---|
| T | item | 
Returns
| Type | Description | 
|---|---|
| Int32 | 
InitializeBehaviour(NetworkBehaviour, Int32)
Internal function.
Declaration
public void InitializeBehaviour(NetworkBehaviour beh, int cmdHash)Parameters
| Type | Name | Description | 
|---|---|---|
| NetworkBehaviour | beh | The behaviour the list belongs to. | 
| Int32 | cmdHash | Identifies this list. | 
Insert(Int32, T)
Same as List::Insert() but also inserts into list on clients.
Declaration
public void Insert(int index, T item)Parameters
| Type | Name | Description | 
|---|---|---|
| Int32 | index | Where to insert the item. | 
| T | item | Item to insert. | 
Remove(T)
Same as List:Remove except removes on clients also.
Declaration
public bool Remove(T item)Parameters
| Type | Name | Description | 
|---|---|---|
| T | item | Item to remove. | 
Returns
| Type | Description | 
|---|---|
| Boolean | 
RemoveAt(Int32)
Same as List:Remove except it removes the index on clients also.
Declaration
public void RemoveAt(int index)Parameters
| Type | Name | Description | 
|---|---|---|
| Int32 | index | Index to remove. | 
SerializeItem(NetworkWriter, T)
This is used to write a value object from a SyncList to a stream.
Declaration
protected abstract void SerializeItem(NetworkWriter writer, T item)Parameters
| Type | Name | Description | 
|---|---|---|
| NetworkWriter | writer | Stream to write to. | 
| T | item | Item to write. |