-
Notifications
You must be signed in to change notification settings - Fork 450
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
fix: notification of missing networkobject on standalone networkbehaviour #1808
Conversation
…orkobject-on-standalone-networkbehaviour
|
||
// 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)", |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
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
Testing and Documentation
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:

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:
