You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Cannot Create Multiple Network Prefab Overrides That Target Same Network Prefab as Override [MTT-7399] (#2710)
* fix
WIP fix for prefab overrides
* update
Removing restriction on PrefabIdHash.
No longer using OverrideToNetworkPrefab.
* update
Removing remains of OverrideToNetworkPrefab
* fix: validation
Putting back the NetworkPrefabs.OverrideToNetworkPrefab to avoid validation issues.
* Update NetworkObject.cs
Removing commented out code.
* update
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.
* style
spelling in xml API
minor rewording
* style
expanded upon the GetNetworkObjectToSpawn description
* style
fixing namespace ordinal ordering
* update
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.
* test and update
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.
* test update and fix
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).
* style
null check standard adjustment
* update
Adding logic to only spawn override (as a default) when running as a host.
* update
Repopulating the override dictionary to avoid breaking any user's project that utilizes it.
Added NetworkObject.InstantiateAndSpawn method.
* update
Adding change log entries.
* update
Updating how errors and warning messages are handled.
* test
Validating that all error messages occur when expected.
* style
removing CR and adding an s to the end of TestsInstantiateAndSpawnErrors
* fix
Putting the OverrideToNetworkPrefab check in the right location.
* update
Adding back the OverrideToNetworkPrefab to continue to support the legacy manual instantiate and spawn usage pattern.
Updated comments to reflect this and to point users to use InstantiateAndSpawn methods.
* update
Adding a static version of InstantiateAndSpawn to NetworkObject.
* Test
Adding a test pass for validating that the legacy instantiate and spawn usage pattern still works.
---------
Co-authored-by: Unity Netcode CI <[email protected]>
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/CHANGELOG.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
18
18
- Added `NetworkManager.ServerIsHost` and `NetworkBehaviour.ServerIsHost` to allow a client to tell if it is connected to a host or to a dedicated server (#2762)
19
19
- Added `SceneEventProgress.SceneManagementNotEnabled` return status to be returned when a `NetworkSceneManager` method is invoked and scene management is not enabled. (#2735)
20
20
- Added `SceneEventProgress.ServerOnlyAction` return status to be returned when a `NetworkSceneManager` method is invoked by a client. (#2735)
21
+
- Added `NetworkObject.InstantiateAndSpawn` and `NetworkSpawnManager.InstantiateAndSpawn` methods to simplify prefab spawning by assuring that the prefab is valid and applies any override prior to instantiating the `GameObject` and spawning the `NetworkObject` instance. (#2710)
21
22
22
23
### Fixed
23
24
@@ -33,6 +34,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
33
34
- Fixed issue where a parented in-scene placed NetworkObject would be destroyed upon a client or server exiting a network session but not unloading the original scene in which the NetworkObject was placed. (#2737)
34
35
- Fixed issue where during client synchronization and scene loading, when client synchronization or the scene loading mode are set to `LoadSceneMode.Single`, a `CreateObjectMessage` could be received, processed, and the resultant spawned `NetworkObject` could be instantiated in the client's currently active scene that could, towards the end of the client synchronization or loading process, be unloaded and cause the newly created `NetworkObject` to be destroyed (and throw and exception). (#2735)
35
36
- Fixed issue where a `NetworkTransform` instance with interpolation enabled would result in wide visual motion gaps (stuttering) under above normal latency conditions and a 1-5% or higher packet are drop rate. (#2713)
37
+
- Fixed issue where you could not have multiple source network prefab overrides targeting the same network prefab as their override. (#2710)
36
38
37
39
### Changed
38
40
- Changed the server or host shutdown so it will now perform a "soft shutdown" when `NetworkManager.Shutdown` is invoked. This will send a disconnect notification to all connected clients and the server-host will wait for all connected clients to disconnect or timeout after a 5 second period before completing the shutdown process. (#2789)
@@ -41,6 +43,11 @@ Additional documentation and release notes are available at [Multiplayer Documen
41
43
-`NetworkManager.ConnectedClientsIds` is now accessible on the client side and will contain the list of all clients in the session, including the host client if the server is operating in host mode (#2762)
42
44
- Changed `NetworkSceneManager` to return a `SceneEventProgress` status and not throw exceptions for methods invoked when scene management is disabled and when a client attempts to access a `NetworkSceneManager` method by a client. (#2735)
43
45
- Changed `NetworkTransform` authoritative instance tick registration so a single `NetworkTransform` specific tick event update will update all authoritative instances to improve perofmance. (#2713)
46
+
- Changed `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. (#2710)
47
+
- Changed in-scene placed `NetworkObject`s now store their source network prefab asset's `GlobalObjectIdHash` internally that is used, when scene management is disabled, by clients to spawn the correct prefab even if the `NetworkPrefab` entry has an override. This does not impact dynamically spawning the same prefab which will yield the override on both host and client. (#2710)
48
+
- Changed in-scene placed `NetworkObject`s no longer require a `NetworkPrefab` entry with `GlobalObjectIdHash` override in order for clients to properly synchronize. (#2710)
49
+
- Changed in-scene placed `NetworkObject`s now set their `IsSceneObject` value when generating their `GlobalObjectIdHash` value. (#2710)
50
+
- Changed the default `NetworkConfig.SpawnTimeout` value from 1.0s to 10.0s. (#2710)
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Runtime/Configuration/NetworkConfig.cs
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -132,7 +132,7 @@ public class NetworkConfig
132
132
/// The amount of time a message should be buffered if the asset or object needed to process it doesn't exist yet. If the asset is not added/object is not spawned within this time, it will be dropped.
133
133
/// </summary>
134
134
[Tooltip("The amount of time a message should be buffered if the asset or object needed to process it doesn't exist yet. If the asset is not added/object is not spawned within this time, it will be dropped")]
// This can happen if a user tries to make several GlobalObjectIdHash values point to the same target
305
-
Debug.LogError($"{nameof(NetworkPrefab)} (\"{networkObject.name}\") has a duplicate {nameof(NetworkObject.GlobalObjectIdHash)} target entry value of: {target}!");
0 commit comments