-
Notifications
You must be signed in to change notification settings - Fork 450
refactor: assign auto-incremented GlobalObjectIdHash as a fallback in MultiInstanceHelpers.MakeNetworkObjectTestPrefab() #1094
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
… MultiInstanceHelpers.MakeNetworkObjectTestPrefab()
// Fallback to auto-increment if generation fails | ||
if (networkObject.GlobalObjectIdHash == default) | ||
{ | ||
networkObject.GlobalObjectIdHash = ++s_AutoIncrementGlobalObjectIdHashCounter; | ||
} | ||
|
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.
this is the main addition
@@ -214,7 +215,7 @@ public class CoroutineResultWrapper<T> | |||
/// </summary> | |||
/// <param name="networkObject">The networkObject to be treated as Prefab</param> | |||
/// <param name="globalObjectIdHash">The GlobalObjectId to force</param> | |||
public static void MakeNetworkedObjectTestPrefab(NetworkObject networkObject, uint globalObjectIdHash = default) | |||
public static void MakeNetworkObjectTestPrefab(NetworkObject networkObject, uint globalObjectIdHash = default) |
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.
also using this as a chance to correct the method name here too
server.NetworkConfig.NetworkPrefabs.Add(new NetworkPrefab { Prefab = m_PlayerPrefabOverride }); | ||
foreach (var client in clients) | ||
{ | ||
client.NetworkConfig.NetworkPrefabs.Add(new NetworkPrefab { Prefab = m_PlayerPrefabOverride }); | ||
} |
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.
also this PR exposed this issue here too (it should've registered prefabs with networkmanagers but never did).
so, we're killing 2 issues with 1 fix here :)
f898733
to
24cc69a
Compare
Assert.AreEqual(Client.LocalClientId, objectSpawned.Connection.Id); | ||
Assert.AreEqual(NewNetworkObjectName, objectSpawned.NetworkId.Name); | ||
Assert.AreEqual($"{k_NewNetworkObjectName}(Clone)", objectSpawned.NetworkId.Name); |
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.
@becksebenius-unity FYI for changes in this file. tests were quite tricky — I think they're more reliable now.
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.
Awesome! I think @josiemessa will be interested too
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.
LGTM!
…in `MultiInstanceHelpers.MakeNetworkObjectTestPrefab()` + fix flaky tests exposed by this fix (Unity-Technologies#1094) * refactor: assign auto-incremented GlobalObjectIdHash as a fallback in MultiInstanceHelpers.MakeNetworkObjectTestPrefab() * fix MultiClientConnectionApproval.ConnectionApproval() test * refactor Removing DefaultPayerGlobalObjectIdHashValue with new GlobalObjectIdHash goodness. * fix NetworkObjectMetricsTests * remove `DefaultPayerGlobalObjectIdHashValue` from OwnershipChangeMetricsTests
a quick follow-up refactor after PR #1092