Skip to content

refactor: FindObject(s)OfType now filters NetworkManagers #763

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 12 commits into from
Apr 27, 2021

Conversation

TwoTenPvP
Copy link
Contributor

No description provided.

… can now be overriden

BREAKING CHANGE: Static lifecycle properties in NetworkBehaviour are no longer static
@TwoTenPvP TwoTenPvP changed the base branch from develop to singleton-removal-network-object April 23, 2021 11:33
@0xFA11
Copy link
Contributor

0xFA11 commented Apr 23, 2021

PR is targeting singleton-removal-network-object branch, is this intended?

@TwoTenPvP
Copy link
Contributor Author

TwoTenPvP commented Apr 23, 2021

PR is targeting singleton-removal-network-object branch, is this intended?

Yeah

for (int i = 0; i < networkObjects.Length; i++)
{
if (networkObjects[i].IsSceneObject == null)
if (networkObjects[i].NetworkManager == m_NetworkManager)
Copy link
Contributor

Choose a reason for hiding this comment

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

I was looking at this and wondering how this works in practice if you have 2 NM's. I get how you override the NM for a NO. How about for a scene? Or are we saying that just one NM will ever have the scene-defined objects? Then I wonder if the contrary of this is true, is it an error? That is you have a NO that is a scene object that belongs to the NM that is not the one that handles scene objects. If that's true (I know this is a long walk...) then seems like we should throw an exception here.

@@ -499,17 +499,20 @@ internal void DestroyNonSceneObjects()

for (int i = 0; i < networkObjects.Length; i++)
{
if (networkObjects[i].IsSceneObject != null && networkObjects[i].IsSceneObject.Value == false)
if (networkObjects[i].NetworkManager == NetworkManager)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above

Copy link
Contributor

@mattwalsh-unity mattwalsh-unity left a comment

Choose a reason for hiding this comment

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

I'd like to understand a bit more how multi-scene works with multi-NMs and scene objects.

Then depending on this, seems like a multi-scene test is order?

@TwoTenPvP
Copy link
Contributor Author

I'd like to understand a bit more how multi-scene works with multi-NMs and scene objects.

Then depending on this, seems like a multi-scene test is order?

To answer those questions above. Right now you have the same override mechanism for NetworkObjects. By default they go and spawn themselves on the Singleton but if it's manually overriden it will go to that one. Nothing really going on. As for Multi-scene tests where we actually do scene switching. That is not yet covered by this PR and it's something not yet looked into. (As was outlined in the proposal). But I think I should be able to make it work fairly easily. It all really depends on how much I can hack the new GlobalObjectId system. The old PrefabHash system was easy to inject values into.

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.

Looks good.

@TwoTenPvP TwoTenPvP force-pushed the singleton-removal-network-object branch from d77f930 to 84cf1c1 Compare April 27, 2021 12:23
Base automatically changed from singleton-removal-network-object to develop April 27, 2021 13:20
@@ -577,9 +586,12 @@ internal void ClientCollectSoftSyncSceneObjectSweep(NetworkObject[] networkObjec

for (int i = 0; i < networkObjects.Length; i++)
{
if (networkObjects[i].IsSceneObject == null)
if (networkObjects[i].NetworkManager == NetworkManager)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Almost all places use the owner NetworkManager by default.

This is the only place we use FindObjectsOfType and thus aren't filtered yet properly.

@TwoTenPvP TwoTenPvP enabled auto-merge (squash) April 27, 2021 20:13
@TwoTenPvP TwoTenPvP merged commit 75e0977 into develop Apr 27, 2021
@TwoTenPvP TwoTenPvP deleted the singleton-removal-find-objects branch April 27, 2021 20:48
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