com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Can't do operations on `NetworkList` with no `NetworkManager` (offline)

Open PitouGames opened this issue 2 years ago • 6 comments

Description

When using a NetworkList with no NetworkManager in scene (in my solo mode), operations on the list (add, insert, remove, clear...) throws an NullReferenceException. This is because of the use of m_NetworkBehaviour that hasn't been initialized.

NetworkVariable<T> doesn't suffer from this behaviour because a check on m_NetworkBehaviour is made.

Actual Outcome

A null reference exception is thrown an the operation is not done.

Expected Outcome

The operation is done.

Environment

  • OS: Windows 11
  • Unity Version: 2021.3.22f1
  • Netcode Version: develop (and all previous versions)
  • Netcode Commit: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/commit/dfd08d84e535146e8c709b91f9eea62dd05bff1a

PitouGames avatar Apr 30 '23 21:04 PitouGames

Bump! I don't understand why it takes so long for this simple bug I reported and provided a solution. My PR is now waiting for 4 months...

Do you really prefere throwing a NullRefException (breaking code flow, so potentially other things) instead of doing the operation and showing the warning you wrote specially for this case?

PitouGames avatar Aug 19 '23 10:08 PitouGames