com.unity.multiplayer.samples.coop icon indicating copy to clipboard operation
com.unity.multiplayer.samples.coop copied to clipboard

feat: tool to enable monobehaviours only on server or client

Open LPLafontaineB opened this issue 3 years ago • 3 comments

Description (*)

This PR adds a NetworkBehaviour that can be placed on a NetworkObject to make sure certain MonoBehaviours can only be enabled on active servers or active clients by using specific interfaces that those MonoBehaviours would inherit. This would remove that responsibility from those MonoBehaviours. It would also allow us to make some of them not be NetworkBehaviours anymore since it was mostly used for the OnNetworkSpawn to enable/disable themselves.

As an example, I have included in this draft PR an implementation of this feature with the interactive door.

Some pros of this solution:

  • Provides a unified solution for something we currently need to do in a lot of different places
  • Allows us to change some NetworkBehaviours back to just MonoBehaviours
  • Provides a single point on which to configure which MonoBehaviours are executed on clients and which are executred on servers

Cons:

  • Adds weight to the actual prefabs and in-scene GameObjects
  • Needs us to make sure that all MonoBehaviours that should only be enabled on a client/server implement the correct interface and that this NetworkBehaviour is added to every prefab and in-scene GameObject that uses it

Related Pull Requests

Issue Number(s) (*)

Fixes issue(s): When implemented, should fix MTT-1683 & MTT-2433

Manual testing scenarios

  1. ...
  2. ...

Questions or comments

Contribution checklist

  • [ ] Pull request has a meaningful description of its purpose
  • [ ] All commits are accompanied by meaningful commit messages
  • [ ] All new or changed code is covered with unit/integration tests (if applicable)
  • [ ] All automated tests passed successfully (all builds are green)

LPLafontaineB avatar Feb 10 '22 15:02 LPLafontaineB

The issue this PR fixes could also be the cause of MTT-2475, but hard to verify since we don't have consistent reproduction steps for that bug yet

LPLafontaineB avatar Feb 25 '22 16:02 LPLafontaineB

on hold until we have true solution

SamuelBellomo avatar Mar 08 '22 19:03 SamuelBellomo

Adding this for all PRs that have been opened since this new flow has been added. Please add your changelog here project changelog file and/or package changelog file

SamuelBellomo avatar May 12 '22 19:05 SamuelBellomo