Skip to content

chore: Better NetworkBehaviour index out of range message#2295

Merged
JesseOlmer merged 6 commits intodevelopfrom
chore/better-nbindex-error
Nov 3, 2022
Merged

chore: Better NetworkBehaviour index out of range message#2295
JesseOlmer merged 6 commits intodevelopfrom
chore/better-nbindex-error

Conversation

@JesseOlmer
Copy link
Copy Markdown
Contributor

Changes the error message to be more easily actionable for users

Changelog

  • Changed: Provide a more actionable error message when the framework encounters a NB index out of range

Testing and Documentation

  • No tests have been added.
  • No documentation changes or additions were necessary.

Jesse Olmer added 2 commits November 2, 2022 11:30
if (NetworkLog.CurrentLogLevel <= LogLevel.Error)
{
NetworkLog.LogError($"Behaviour index was out of bounds. Did you mess up the order of your {nameof(NetworkBehaviour)}s?");
NetworkLog.LogError($"NetworkBehaviour index was out of bounds for {name}. NetworkBehaviours must be the same, and in the same order, between server and client.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we replace both 'NetworkBehaviour' with '{nameof(NetworkBehaviour)}'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also perhaps
NetworkBehaviours must be the same => NetworkBehaviours must have the same components

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the nameof change. Did not make the wording change - NetworkBehaviours ARE components, they don't contain components. Perhaps you meant NetworkObject? But I'd still rather not make that change because it's really not accurate either. This is a relatively complicated situation and a long error message feels unwarranted here.

In case you're curious, the word-salad criteria is:
"All NetworkBehaviours on an object containing a NetworkObject component, including child objects, but only those which don't have their own NetworkObject component, must match exactly in their number, as well as type and order (although neither are checked in this case)."

@JesseOlmer JesseOlmer marked this pull request as ready for review November 2, 2022 19:15
@JesseOlmer JesseOlmer requested a review from a team as a code owner November 2, 2022 19:15
Comment thread com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
Copy link
Copy Markdown
Member

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@JesseOlmer JesseOlmer merged commit 083bb63 into develop Nov 3, 2022
@JesseOlmer JesseOlmer deleted the chore/better-nbindex-error branch November 3, 2022 14:45
jakobbbb pushed a commit to GooseGirlGames/com.unity.netcode.gameobjects that referenced this pull request Feb 22, 2023
…nologies#2295)

Changes the error message to be more easily actionable for users

Co-authored-by: Noel Stephens <noel.stephens@unity3d.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants