-
Notifications
You must be signed in to change notification settings - Fork 435
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: Cannot Create Multiple Network Prefab Overrides That Target Same Network Prefab as Override [MTT-7399] #2710
Conversation
Putting back the NetworkPrefabs.OverrideToNetworkPrefab to avoid validation issues.
Removing commented out code.
Adding a new method: NetworkSpawnManager.InstantiateAndSpawn that handles several steps for users. Basically passing in a prefab NetworkObject will instantiate, spawn, and then return the spawned prefab instance. This takes into account prefab overrides. Added a manual test "SimpleSpawn" to manually validate the updates.
Added some additional improvements to the simple spawn sample/manual test that also provides an example of the legacy/alternate way to spawn prefabs along with unique prefabs that are named appropriately for each scenario while also setting the color of the NetworkObjectId label to the assigned owner/client assigned color.
This update includes automatic linking of in-scene placed NetworkObjects to their source prefab asset. This is specifically useful for when scene management is disabled as it removes the requirement to create a prefab override per in-scene placed NetworkObject. This also assures that a prefab with an override can still be used as an in-scene placed NetworkObject without the client spawning the overide when scene management is disabled while also still spawing the override of the same prefab when dynamically spawned. This also includes an integration test to validate both with and without scene management enabled that clients synchronize to the proper prefab instance.
Reverting the NetworkPrefabs change and just using the SourcePrefabToOverride. Renamed InScenePlacedSourceGlobalObjectId to InScenePlacedSourceGlobalObjectIdHash to avoid confusion. Updated the PrefabExtendedTests and test assets to include the scenario that is not handled when scnee management is disabled (i.e. in-scene defined NetworkObjects).
if (OverrideToNetworkPrefab.ContainsKey(target)) | ||
{ | ||
// If so, just return false and don't attempt to add another. | ||
return false; |
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.
Weren't we going to leave this check out?
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.
😞
Yes... it is in the wrong location... need to write another test.
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.
Ok... check the update... that is where that check should be.
This resolves the issue where you could not have multiple source network prefab overrides targeting the same network prefab as their override.
MTT-7399
** Includes additional spawning sample and integration test specific assets (required for integration test)
Discovered when supporting user requests about NGO documentation in Isssue-1053
Addeded/Changed Functionality Update
NetworkSpawnManafer.InstantiateAndSpawn
that simplifies the spawning of a prefab asset without having to worry about instantiating or making sure to get the overridden version of the prefab when spawning.NetworkObject
s to their source prefab asset'sGlobalObjetIdHash
which removes the high user pain associated with having to create a prefab override per in-scene placed network prefab instance within theNetworkPrefabList
.NetworkObject
.NetworkObject
without the client spawning the override when scene management is disabled while also still being able to dynamically spawn the same prefab and still yielding the desired override target prefab.Changelog
NetworkObject.InstantiateAndSpawn
andNetworkSpawnManager.InstantiateAndSpawn
methods to simplify prefab spawning by assuring that the prefab is valid and applies any override prior to instantiating theGameObject
and spawning theNetworkObject
instance.NetworkPrefabs.OverrideToNetworkPrefab
dictionary is no longer used/populated due to it ending up being related to a regression bug and not allowing more than one override to be assigned to a network prefab asset.NetworkObject
s now store their source network prefab asset'sGlobalObjectIdHash
internally that is used, when scene management is disabled, by clients to spawn the correct prefab even if theNetworkPrefab
entry has an override. This does not impact dynamically spawning the same prefab which will yield the override on both host and client.NetworkObject
s no longer require aNetworkPrefab
entry withGlobalObjectIdHash
override in order for clients to properly synchronize.NetworkObject
s now set theirIsSceneObject
value when generating theirGlobalObjectIdHash
value.NetworkConfig.SpawnTimeout
value from 1.0s to 10.0s.Testing and Documentation
PrefabExtendedTests.TestPrefabsSpawning