Unity-Technologies / multiplayer-community-contributions

Community contributions to Unity Multiplayer Networking products and services.
MIT License
415 stars 160 forks source link

NetworkDictionary read values should be updated to pass by ref #236

Open bentrewhella opened 11 months ago

bentrewhella commented 11 months ago

In NGO 1.5.1, NetworkVariableSerialization.Read(reader, ref key) takes ref rather than out. Network Dictionary should be updated to something like:

public override void ReadField(FastBufferReader reader)
        {
            m_Keys.Clear();
            m_Values.Clear();

            reader.ReadValueSafe(out ushort count);

            for (int i = 0; i < count; i++)
            {
                var key = new TKey();
                var value = new TValue();
                NetworkVariableSerialization<TKey>.Read(reader, ref key);
                NetworkVariableSerialization<TValue>.Read(reader, ref value);
                m_Keys.Add(key);
                m_Values.Add(value);
            }
        }
Misiek-97 commented 3 months ago

` public override void ReadField(FastBufferReader reader) { m_Keys.Clear(); m_Values.Clear();

        reader.ReadValueSafe(out ushort count);

        for (int i = 0; i < count; i++)
        {
            TKey key = new TKey();
            TValue value = new TValue();
            NetworkVariableSerialization<TKey>.Read(reader, ref key);
            NetworkVariableSerialization<TValue>.Read(reader, ref value);
            m_Keys.Add(key);
            m_Values.Add(value);
        }
    }`

I'm no expert on these, but I've changed to this in multiple places according to Rider's IntelliSense - got rid of the errors but no idea if this is the solution.