Skip to content

fix: notification of missing networkobject on standalone networkbehaviour #1808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Mar 16, 2022

This addresses the issue where a user could add a NetworkBehaviour to a GameObject and forget to not also include a NetworkObject and never be notified that NetworkBehaviours require a GameObject in order to function properly.

MTT-1353

Changelog

com.unity.netcode.gameobjects

  • Fixed: User never being notified in the editor that a NetworkBehaviour requires a NetworkObject to function properly.

Testing and Documentation

  • No tests have been added.

Additional Information

The first time a user adds a NetworkBehaviour to a GameObject that doesn't have a NetworkObject they will be presented with the following dialog box:
image
If the user selects "Yes - Do not show me this message again on this machine", then from that point forward if a NetworkBehaviour is added to a GameObject that doesn't already have a NetworkObject...it will automatically add one.

This setting can be reset (i.e. dialog box will appear the next time) via this drop down menu item:
image

This provides users with feedback when they try to add a NetworkBehaviour to a GameObject that does not have a NetworkObject already assigned to it.

It also provides users with the option to always add a NetworkObject with the ability to reset that setting.
updated comments.
updated some comments for clarity.

// Notify and provide the option to add it one time, always add a NetworkObject, or do nothing and let the user manually add it
if (EditorUtility.DisplayDialog($"{nameof(NetworkBehaviour)}s require a {nameof(NetworkObject)}",
$"{gameObject.name} does not have a {nameof(NetworkObject)} component. Would you like to add one now?", "Yes", "No (manually add it)",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I really like that this popup gives the option to automatically add it. I was actually coming into this expecting to bring up a concern about being annoyed by popups if I add the objects in the wrong order, and here you already thought of that and made a great solution. I didn't even have a solution in mind, I was just going to ask "do we care?" - great work!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Though as a minor thing, the text of this popup disagrees with the comment... the comment suggests this dialogue will give the user the choice between "once", "always", or "never", but this text gives the choice between "yes", or "no".

Copy link
Collaborator

Choose a reason for hiding this comment

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

(Though I may be misreading that, given I don't know what DialogOptOutDecisionType.ForThisMachine does.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah... this is a "Unity Thing" that basically gives the option to always/automatically select "Yes" for the scenario that invokes that dialog box (i.e. so a user can see it once, select the extended "Yes-Do not show this...", and then it will always automatically add a NetworkObject component if you first add a NetworkBehaviour component to a GameObject with no NetworkObject component.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, neat. Comment withdrawn then!

@NoelStephensUnity NoelStephensUnity merged commit 3146dba into develop Mar 16, 2022
@NoelStephensUnity NoelStephensUnity deleted the fix/mtt-1353-notification-of-missing-networkobject-on-standalone-networkbehaviour branch March 16, 2022 23:15
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.

3 participants