Skip to content

test: Nested NetworkObjects in prefabs throws a warning [MTT-2976] #1969

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

Merged
merged 7 commits into from
May 19, 2022

Conversation

TwoTenPvP
Copy link
Contributor

Prevents nested NetworkObjects from existing and being created.

MTT-2976

Changelog

  • Fixed: Nested NetworkObjects can no longer be created

Testing and Documentation

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

@TwoTenPvP TwoTenPvP requested a review from a team as a code owner May 16, 2022 13:57
@WhippetsAintDogs
Copy link

WhippetsAintDogs commented May 17, 2022

Hi @TwoTenPvP, in our project we have Prefabs that have root a NetworkObject and nested NetworkObjects. We've handled them with a component that will unparent them on Awake (upon instantiation, but before network spawning) and that will Spawn them on the next network tick following the network spawning of the root NetworkObject. On the client side, we have a PrefabHandler registered dynamically that will provide the nested NetworkObject instance, the one obtained from the prefab instantiation and that was unparented on Awake, to the spawn call therefore binding their network "identities" without doing an extra instantiation / duplication.

It allows us to have nested NetworkObjects in the editor (in the prefabs) which help us visualizing / positioning them, but as soon as their parent is spawn, they are unparented and spawned as well without duplication (we bind the existing instance, not doing another Instantiate). We find that pretty convenient. Are you sure you want to enforce such restrictions with an editor check? How about a warning instead? 👀

@TwoTenPvP
Copy link
Contributor Author

Hi @TwoTenPvP, in our project we have Prefabs that have root a NetworkObject and nested NetworkObjects. We've handled them with a component that will unparent them on Awake (upon instantiation, but before network spawning) and that will Spawn them on the next network tick following the network spawning of the root NetworkObject. On the client side, we have a PrefabHandler registered dynamically that will provide the nested NetworkObject instance, the one obtained from the prefab instantiation and that was unparented on Awake, to the spawn call therefore binding their network "identities" without doing an extra instantiation / duplication.

It allows us to have nested NetworkObjects in the editor (in the prefabs) which help us visualizing / positioning them, but as soon as their parent is spawn, they are unparented and spawned as well without duplication (we bind the existing instance, not doing another Instantiate). We find that pretty convenient. Are you sure you want to enforce such restrictions with an editor check? How about a warning instead? eyes

Hello! It has been done with a warning now.
Thanks for reaching out with your concerns!

@TwoTenPvP TwoTenPvP changed the title fix: Nested NetworkObjects can no longer be created test: Nested NetworkObjects in prefabs throws a warning May 19, 2022
@0xFA11 0xFA11 requested a review from NoelStephensUnity May 19, 2022 14:03
@0xFA11 0xFA11 changed the title test: Nested NetworkObjects in prefabs throws a warning test: Nested NetworkObjects in prefabs throws a warning [MTT-2976] May 19, 2022
Copy link
Collaborator

@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!

@0xFA11 0xFA11 merged commit a4edf18 into develop May 19, 2022
@0xFA11 0xFA11 deleted the nested-network-objects branch May 19, 2022 16:02
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