docs.unity3d.com
    Show / Hide Table of Contents

    Class NetworkDictionary<TKey, TValue>

    Event based NetworkVariable container for syncing Dictionaries

    Inheritance
    Object
    NetworkVariableBase
    NetworkDictionary<TKey, TValue>
    Inherited Members
    NetworkVariableBase.DefaultReadPerm
    NetworkVariableBase.DefaultWritePerm
    NetworkVariableBase.ReadPerm
    NetworkVariableBase.WritePerm
    NetworkVariableBase.GetBehaviour()
    NetworkVariableBase.Initialize(NetworkBehaviour)
    NetworkVariableBase.SetDirty(Boolean)
    NetworkVariableBase.CanClientRead(UInt64)
    NetworkVariableBase.CanClientWrite(UInt64)
    NetworkVariableBase.Name
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Cloud.Presence.Runtime
    Syntax
    public class NetworkDictionary<TKey, TValue> : NetworkVariableBase, IDisposable where TKey : struct, IEquatable<TKey> where TValue : struct, IEquatable<TValue>
    Type Parameters
    Name Description
    TKey

    The type for the dictionary keys

    TValue

    The type for the dictionary values

    Constructors

    NetworkDictionary()

    Creates a NetworkDictionary with the default value and settings

    Declaration
    public NetworkDictionary()

    NetworkDictionary(IDictionary<TKey, TValue>)

    Creates a NetworkDictionary with a custom value and custom settings

    Declaration
    public NetworkDictionary(IDictionary<TKey, TValue> values)
    Parameters
    Type Name Description
    IDictionary<TKey, TValue> values

    The initial value to use for the NetworkDictionary

    NetworkDictionary(NetworkVariableReadPermission, IDictionary<TKey, TValue>)

    Creates a NetworkDictionary with the default value and custom settings

    Declaration
    public NetworkDictionary(NetworkVariableReadPermission readPerm, IDictionary<TKey, TValue> values)
    Parameters
    Type Name Description
    NetworkVariableReadPermission readPerm

    The read permission to use for the NetworkDictionary

    IDictionary<TKey, TValue> values

    The initial value to use for the NetworkDictionary

    Properties

    Count

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32

    Item[TKey]

    Declaration
    public TValue this[TKey key] { get; set; }
    Parameters
    Type Name Description
    TKey key
    Property Value
    Type Description
    TValue

    Keys

    Declaration
    public IEnumerable<TKey> Keys { get; }
    Property Value
    Type Description
    IEnumerable<TKey>

    Values

    Declaration
    public IEnumerable<TValue> Values { get; }
    Property Value
    Type Description
    IEnumerable<TValue>

    Methods

    Add(TKey, TValue)

    Declaration
    public void Add(TKey key, TValue value)
    Parameters
    Type Name Description
    TKey key
    TValue value

    Clear()

    Declaration
    public void Clear()

    ContainsKey(TKey)

    Declaration
    public bool ContainsKey(TKey key)
    Parameters
    Type Name Description
    TKey key
    Returns
    Type Description
    Boolean

    Dispose()

    Declaration
    public override void Dispose()
    Overrides
    NetworkVariableBase.Dispose()

    GetEnumerator()

    Declaration
    public IEnumerator<KeyValue<TKey, TValue>> GetEnumerator()
    Returns
    Type Description
    IEnumerator<KeyValue<TKey, TValue>>

    IsDirty()

    Declaration
    public override bool IsDirty()
    Returns
    Type Description
    Boolean
    Overrides
    NetworkVariableBase.IsDirty()

    Read<T>(FastBufferReader, out T)

    Declaration
    protected void Read<T>(FastBufferReader reader, out T key)
        where T : struct, IEquatable<T>
    Parameters
    Type Name Description
    FastBufferReader reader
    T key
    Type Parameters
    Name Description
    T

    ReadDelta(FastBufferReader, Boolean)

    Declaration
    public override void ReadDelta(FastBufferReader reader, bool keepDirtyDelta)
    Parameters
    Type Name Description
    FastBufferReader reader
    Boolean keepDirtyDelta
    Overrides
    NetworkVariableBase.ReadDelta(FastBufferReader, Boolean)

    ReadField(FastBufferReader)

    Declaration
    public override void ReadField(FastBufferReader reader)
    Parameters
    Type Name Description
    FastBufferReader reader
    Overrides
    NetworkVariableBase.ReadField(FastBufferReader)

    Remove(TKey)

    Declaration
    public bool Remove(TKey key)
    Parameters
    Type Name Description
    TKey key
    Returns
    Type Description
    Boolean

    ResetDirty()

    Declaration
    public override void ResetDirty()
    Overrides
    NetworkVariableBase.ResetDirty()

    TryGetValue(TKey, out TValue)

    Declaration
    public bool TryGetValue(TKey key, out TValue value)
    Parameters
    Type Name Description
    TKey key
    TValue value
    Returns
    Type Description
    Boolean

    Write<T>(FastBufferWriter, T)

    Declaration
    protected void Write<T>(FastBufferWriter writer, T key)
        where T : struct, IEquatable<T>
    Parameters
    Type Name Description
    FastBufferWriter writer
    T key
    Type Parameters
    Name Description
    T

    WriteDelta(FastBufferWriter)

    Declaration
    public override void WriteDelta(FastBufferWriter writer)
    Parameters
    Type Name Description
    FastBufferWriter writer
    Overrides
    NetworkVariableBase.WriteDelta(FastBufferWriter)

    WriteField(FastBufferWriter)

    Declaration
    public override void WriteField(FastBufferWriter writer)
    Parameters
    Type Name Description
    FastBufferWriter writer
    Overrides
    NetworkVariableBase.WriteField(FastBufferWriter)

    Events

    OnDictionaryChanged

    The callback to be invoked when the dictionary gets changed

    Declaration
    public event NetworkDictionary<TKey, TValue>.OnDictionaryChangedDelegate OnDictionaryChanged
    Event Type
    Type Description
    NetworkDictionary.OnDictionaryChangedDelegate<>

    Extension Methods

    GenericDataExtensions.SerializeToByteArray(Object)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023