Closed
Description
Describe the bug
When calling NetworkList<T>.Contains(T)
it is returning the opposite bool of what I'm expecting.
To Reproduce
Steps to reproduce the behavior:
- Add an element to a NetworkList
Debug.Log
the return value from:NetworkList<T>.Contains(T)
passing in the element you addedDebug.Log
the return value from:NetworkList<T>.Contains(T)
passing in an element you didn't add- See log output
Actual outcome
False
True
Expected outcome
True
False
Screenshots
Looking at the source, it is returning true if the index of the element is -1, otherwise false. I'm pretty sure this is the cause of the issue.
public bool Contains(T item)
{
int index = NativeArrayExtensions.IndexOf(m_List, item);
return index == -1;
}
Environment (please complete the following information):
- OS: [Windows 10]
- Unity Version: [2021.1]
- Netcode Version: [v1.0.0-pre.2]