18using System.Collections.Generic;
19using System.Runtime.CompilerServices;
31 [SerializeField] T _Value;
35 public virtual T Value
37 [MethodImpl(MethodImplOptions.AggressiveInlining)]
62 InvokeCallback(old, value);
74 public event Action<T, T> Callback;
79 [MethodImpl(MethodImplOptions.AggressiveInlining)]
80 protected virtual void InvokeCallback(T oldValue, T newValue) =>
81 Callback?.Invoke(oldValue, newValue);
98 Debug.LogWarning($
"Use explicit {nameof(SyncVarGameObject)} class instead of {nameof(SyncVar<T>)}<GameObject>. It stores netId internally for persistence.");
101 Debug.LogWarning($
"Use explicit {nameof(SyncVarNetworkIdentity)} class instead of {nameof(SyncVar<T>)}<NetworkIdentity>. It stores netId internally for persistence.");
104 Debug.LogWarning($
"Use explicit SyncVarNetworkBehaviour class instead of {nameof(SyncVar<T>)}<NetworkBehaviour>. It stores netId internally for persistence.");
113 [MethodImpl(MethodImplOptions.AggressiveInlining)]
114 public static implicit
operator T(SyncVar<T> field) => field.Value;
118 [MethodImpl(MethodImplOptions.AggressiveInlining)]
119 public static implicit
operator SyncVar<T>(T value) =>
new SyncVar<T>(value);
122 [MethodImpl(MethodImplOptions.AggressiveInlining)]
125 [MethodImpl(MethodImplOptions.AggressiveInlining)]
128 [MethodImpl(MethodImplOptions.AggressiveInlining)]
131 [MethodImpl(MethodImplOptions.AggressiveInlining)]
137 [MethodImpl(MethodImplOptions.AggressiveInlining)]
138 public bool Equals(T other) =>
142 EqualityComparer<T>.Default.Equals(Value, other);
146 public override string ToString() => Value.ToString();
NetworkClient with connection to server.
static bool active
active is true while a client is connecting/connected
Network Reader for most simple types like floats, ints, buffers, structs, etc. Use NetworkReaderPool....
Network Writer for most simple types like floats, ints, buffers, structs, etc. Use NetworkWriterPool....
SyncObjects sync state between server and client. E.g. SyncLists.
Action OnDirty
Used internally to set owner NetworkBehaviour's dirty mask bit when changed.
override void OnDeserializeDelta(NetworkReader reader)
Reads the changes made to the object since last sync
override void OnSerializeDelta(NetworkWriter writer)
Write the changes made to the object since last sync
override void OnDeserializeAll(NetworkReader reader)
Reads a full copy of the object
override void ClearChanges()
Discard all the queued changes
override void Reset()
Resets the SyncObject so that it can be re-used
override void OnSerializeAll(NetworkWriter writer)
Write a full copy of the object