From 94cb5acb028a62581582d110f9e6d6c18af54673 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 22 Oct 2025 11:09:43 -0400 Subject: [PATCH 1/9] fix: GetSceneMapping final int->ulong conversion --- .yamato/_triggers.yml | 5 +- .../SceneManagement/NetworkSceneHandle.cs | 8 +- .../SceneManagement/NetworkSceneManager.cs | 113 ++++++++++++------ 3 files changed, 88 insertions(+), 38 deletions(-) diff --git a/.yamato/_triggers.yml b/.yamato/_triggers.yml index 72145210c2..a7689dab7d 100644 --- a/.yamato/_triggers.yml +++ b/.yamato/_triggers.yml @@ -87,8 +87,9 @@ pr_code_changes_checks: # Coverage on other standalone machines is present in Nightly job so it's enough to not run all of them for PRs # desktop_standalone_test and cmb_service_standalone_test are both reusing desktop_standalone_build dependency so we run those in the same configuration on PRs to reduce waiting time. # Note that our daily tests will anyway run both test configurations in "minimal supported" and "trunk" configurations - - .yamato/desktop-standalone-tests.yml#desktop_standalone_test_testproject_ubuntu_il2cpp_trunk - - .yamato/cmb-service-standalone-tests.yml#cmb_service_standalone_test_testproject_ubuntu_il2cpp_trunk + # TODO: Move these tests back to trunk + - .yamato/desktop-standalone-tests.yml#desktop_standalone_test_testproject_ubuntu_il2cpp_6000.4 + - .yamato/cmb-service-standalone-tests.yml#cmb_service_standalone_test_testproject_ubuntu_il2cpp_6000.4 triggers: expression: |- (pull_request.comment eq "ngo" OR diff --git a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneHandle.cs b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneHandle.cs index c0cb3fc042..9a2053c2ed 100644 --- a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneHandle.cs +++ b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneHandle.cs @@ -92,8 +92,14 @@ internal NetworkSceneHandle(int handle, bool asMock) /// /// Implicit conversion from to . /// - /// + /// The SceneHandle to covert public static implicit operator NetworkSceneHandle(SceneHandle handle) => new(handle); + + /// + /// Implicit conversion from to . + /// + /// The NetworkSceneHandle to convert + public static implicit operator SceneHandle(NetworkSceneHandle handle) => handle.m_Handle; #else /// /// Implicit conversion from to . diff --git a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs index 8f852a0fd6..8dab0e64f5 100644 --- a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs @@ -3115,19 +3115,67 @@ public struct SceneMap : INetworkSerializable /// The name of the scene /// public string SceneName; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION + /// + /// The scene's server handle (a.k.a network scene handle) + /// + /// + /// This is deprecated in favor of ServerSceneHandle + /// + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> ServerSceneHandle")] +#else /// /// The scene's server handle (a.k.a network scene handle) /// +#endif public int ServerHandle; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION + /// + /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). + /// + /// + /// This is deprecated in favor of MappedLocalSceneHandle + /// + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> MappedLocalSceneHandle")] +#else /// /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). /// +#endif public int MappedLocalHandle; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION + /// + /// The local handle of the scene. + /// + /// + /// This is deprecated in favor of LocalSceneHandle + /// + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> LocalSceneHandle")] +#else /// /// The local handle of the scene. /// +#endif public int LocalHandle; +#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE + /// + /// The scene's server handle (a.k.a network scene handle) + /// + public SceneHandle ServerSceneHandle; + /// + /// The mapped handled. This could be the ServerSceneHandle or LocalSceneHandle depending upon context (client or server). + /// + public SceneHandle MappedLocalSceneHandle; + /// + /// The local handle of the scene. + /// + public SceneHandle LocalSceneHandle; +#endif + /// public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { @@ -3156,43 +3204,38 @@ public void NetworkSerialize(BufferSerializer serializer) where T : IReade public List GetSceneMapping(MapTypes mapType) { var mapping = new List(); - if (mapType == MapTypes.ServerToClient) - { - foreach (var entry in ServerSceneHandleToClientSceneHandle) - { - var scene = ScenesLoaded[entry.Value]; - var sceneIsPresent = scene.IsValid() && scene.isLoaded; - var sceneMap = new SceneMap() - { - MapType = mapType, - ServerHandle = entry.Key.GetRawData(), - MappedLocalHandle = entry.Value.GetRawData(), - LocalHandle = new NetworkSceneHandle(scene.handle).GetRawData(), - Scene = scene, - ScenePresent = sceneIsPresent, - SceneName = sceneIsPresent ? scene.name : "NotPresent", - }; - mapping.Add(sceneMap); - } - } - else + var map = mapType == MapTypes.ServerToClient ? ServerSceneHandleToClientSceneHandle : ClientSceneHandleToServerSceneHandle; + + foreach (var entry in map) { - foreach (var entry in ClientSceneHandleToServerSceneHandle) + var scene = ScenesLoaded[entry.Key]; + var sceneIsPresent = scene.IsValid() && scene.isLoaded; + var sceneMap = new SceneMap() { - var scene = ScenesLoaded[entry.Key]; - var sceneIsPresent = scene.IsValid() && scene.isLoaded; - var sceneMap = new SceneMap() - { - MapType = mapType, - ServerHandle = entry.Key.GetRawData(), - MappedLocalHandle = entry.Value.GetRawData(), - LocalHandle = new NetworkSceneHandle(scene.handle).GetRawData(), - Scene = scene, - ScenePresent = sceneIsPresent, - SceneName = sceneIsPresent ? scene.name : "NotPresent", - }; - mapping.Add(sceneMap); - } + MapType = mapType, + +#pragma warning disable CS0618 // Type or member is obsolete +#if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG + ServerHandle = (int)entry.Key.GetRawData(), + MappedLocalHandle = (int)entry.Value.GetRawData(), + LocalHandle = (int)new NetworkSceneHandle(scene.handle).GetRawData(), +#else + ServerHandle = entry.Key.GetRawData(), + MappedLocalHandle = entry.Value.GetRawData(), + LocalHandle = new NetworkSceneHandle(scene.handle).GetRawData(), +#endif +#pragma warning restore CS0618 // Type or member is obsolete + +#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE + ServerSceneHandle = entry.Key, + MappedLocalSceneHandle = entry.Value, + LocalSceneHandle = scene.handle, +#endif + Scene = scene, + ScenePresent = sceneIsPresent, + SceneName = sceneIsPresent ? scene.name : "NotPresent", + }; + mapping.Add(sceneMap); } return mapping; From ab9bc6f019ddab7288a496332bb6ebac009139f3 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 22 Oct 2025 11:18:23 -0400 Subject: [PATCH 2/9] Update CHANGELOG --- .yamato/_triggers.yml | 3 ++- com.unity.netcode.gameobjects/CHANGELOG.md | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.yamato/_triggers.yml b/.yamato/_triggers.yml index a7689dab7d..8b8d74f86b 100644 --- a/.yamato/_triggers.yml +++ b/.yamato/_triggers.yml @@ -87,7 +87,8 @@ pr_code_changes_checks: # Coverage on other standalone machines is present in Nightly job so it's enough to not run all of them for PRs # desktop_standalone_test and cmb_service_standalone_test are both reusing desktop_standalone_build dependency so we run those in the same configuration on PRs to reduce waiting time. # Note that our daily tests will anyway run both test configurations in "minimal supported" and "trunk" configurations - # TODO: Move these tests back to trunk + + # TODO: Move these tests back to trunk once CMB Service has addressed https://jira.unity3d.com/browse/MTTB-1680 - .yamato/desktop-standalone-tests.yml#desktop_standalone_test_testproject_ubuntu_il2cpp_6000.4 - .yamato/cmb-service-standalone-tests.yml#cmb_service_standalone_test_testproject_ubuntu_il2cpp_6000.4 triggers: diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index ab7434e0fa..beeb949d80 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -11,6 +11,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Added - Added NetworkRigidbody documentation section. (#3664) +- Added new fields to the `SceneMap` struct when using Unity 6.3 or higher. These fields allow referencing scene handles via the new `SceneHandle` struct. (#3734) ### Changed @@ -24,6 +25,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Deprecated +- On Unity 6.5 some `SceneMap` fields that use an `int` to represent a `SceneHandle` are deprecated. (#3734) ### Removed From 48caa1e1dabac4873a507cf54e116c4b66be8097 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 22 Oct 2025 12:06:42 -0400 Subject: [PATCH 3/9] Fix SceneMap serialization --- .../SceneManagement/NetworkSceneManager.cs | 143 +------------ .../Runtime/SceneManagement/SceneMap.cs | 193 ++++++++++++++++++ .../Runtime/SceneManagement/SceneMap.cs.meta | 3 + 3 files changed, 197 insertions(+), 142 deletions(-) create mode 100644 com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs create mode 100644 com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs.meta diff --git a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs index 8dab0e64f5..3fd304857d 100644 --- a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs @@ -3079,123 +3079,6 @@ private void ProcessDeferredCreateObjectMessages() DeferredObjectCreationList.Clear(); } - /// - /// The scene map type . - /// - public enum MapTypes - { - /// - /// Denotes the server to client scene map type. - /// - ServerToClient, - /// - /// Denotes the client to server scene map type. - /// - ClientToServer - } - - /// - /// Provides the status of a loaded scene - /// - public struct SceneMap : INetworkSerializable - { - /// - /// The scene mapping type . - /// - public MapTypes MapType; - /// - /// The struct of the scene mapped. - /// - public Scene Scene; - /// - /// When true, the scene is present. - /// - public bool ScenePresent; - /// - /// The name of the scene - /// - public string SceneName; - -#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION - /// - /// The scene's server handle (a.k.a network scene handle) - /// - /// - /// This is deprecated in favor of ServerSceneHandle - /// - [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> ServerSceneHandle")] -#else - /// - /// The scene's server handle (a.k.a network scene handle) - /// -#endif - public int ServerHandle; - -#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION - /// - /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). - /// - /// - /// This is deprecated in favor of MappedLocalSceneHandle - /// - [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> MappedLocalSceneHandle")] -#else - /// - /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). - /// -#endif - public int MappedLocalHandle; - -#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION - /// - /// The local handle of the scene. - /// - /// - /// This is deprecated in favor of LocalSceneHandle - /// - [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> LocalSceneHandle")] -#else - /// - /// The local handle of the scene. - /// -#endif - public int LocalHandle; - -#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE - /// - /// The scene's server handle (a.k.a network scene handle) - /// - public SceneHandle ServerSceneHandle; - /// - /// The mapped handled. This could be the ServerSceneHandle or LocalSceneHandle depending upon context (client or server). - /// - public SceneHandle MappedLocalSceneHandle; - /// - /// The local handle of the scene. - /// - public SceneHandle LocalSceneHandle; -#endif - - /// - public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter - { - serializer.SerializeValue(ref MapType); - serializer.SerializeValue(ref ScenePresent); - if (serializer.IsReader) - { - SceneName = "Not Present"; - } - if (ScenePresent) - { - serializer.SerializeValue(ref SceneName); - serializer.SerializeValue(ref LocalHandle); - - } - serializer.SerializeValue(ref ServerHandle); - serializer.SerializeValue(ref MappedLocalHandle); - } - } - /// /// Returns the list of all scene mappings when scene management is enabled. /// @@ -3210,31 +3093,7 @@ public List GetSceneMapping(MapTypes mapType) { var scene = ScenesLoaded[entry.Key]; var sceneIsPresent = scene.IsValid() && scene.isLoaded; - var sceneMap = new SceneMap() - { - MapType = mapType, - -#pragma warning disable CS0618 // Type or member is obsolete -#if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG - ServerHandle = (int)entry.Key.GetRawData(), - MappedLocalHandle = (int)entry.Value.GetRawData(), - LocalHandle = (int)new NetworkSceneHandle(scene.handle).GetRawData(), -#else - ServerHandle = entry.Key.GetRawData(), - MappedLocalHandle = entry.Value.GetRawData(), - LocalHandle = new NetworkSceneHandle(scene.handle).GetRawData(), -#endif -#pragma warning restore CS0618 // Type or member is obsolete - -#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE - ServerSceneHandle = entry.Key, - MappedLocalSceneHandle = entry.Value, - LocalSceneHandle = scene.handle, -#endif - Scene = scene, - ScenePresent = sceneIsPresent, - SceneName = sceneIsPresent ? scene.name : "NotPresent", - }; + var sceneMap = new SceneMap(mapType, scene, sceneIsPresent, entry.Key, entry.Value); mapping.Add(sceneMap); } diff --git a/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs b/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs new file mode 100644 index 0000000000..0b9ac059a1 --- /dev/null +++ b/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs @@ -0,0 +1,193 @@ +#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION +using System; +#endif +using UnityEngine.SceneManagement; + +namespace Unity.Netcode +{ + /// + /// The scene map type . + /// + public enum MapTypes + { + /// + /// Denotes the server to client scene map type. + /// + ServerToClient, + /// + /// Denotes the client to server scene map type. + /// + ClientToServer + } + + /// + /// Provides the status of a loaded scene + /// + public struct SceneMap : INetworkSerializable + { + /// + /// The scene mapping type . + /// + public MapTypes MapType; + /// + /// The struct of the scene mapped. + /// + public Scene Scene; + /// + /// When true, the scene is present. + /// + public bool ScenePresent; + /// + /// The name of the scene + /// + public string SceneName; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION + /// + /// The scene's server handle (a.k.a network scene handle) + /// + /// + /// This is deprecated in favor of ServerSceneHandle + /// + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> ServerSceneHandle")] +#else + /// + /// The scene's server handle (a.k.a network scene handle) + /// +#endif + public int ServerHandle; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION + /// + /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). + /// + /// + /// This is deprecated in favor of MappedLocalSceneHandle + /// + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> MappedLocalSceneHandle")] +#else + /// + /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). + /// +#endif + public int MappedLocalHandle; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION + /// + /// The local handle of the scene. + /// + /// + /// This is deprecated in favor of LocalSceneHandle + /// + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> LocalSceneHandle")] +#else + /// + /// The local handle of the scene. + /// +#endif + public int LocalHandle; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE + /// + /// The scene's server handle (a.k.a network scene handle) + /// + public SceneHandle ServerSceneHandle; + /// + /// The mapped handled. This could be the ServerSceneHandle or LocalSceneHandle depending upon context (client or server). + /// + public SceneHandle MappedLocalSceneHandle; + /// + /// The local handle of the scene. + /// + public SceneHandle LocalSceneHandle; +#endif + + private NetworkSceneHandle m_ServerHandle; + private NetworkSceneHandle m_MappedLocalHandle; + private NetworkSceneHandle m_LocalHandle; + + internal SceneMap(MapTypes mapType, Scene scene, bool isScenePresent, NetworkSceneHandle serverHandle, NetworkSceneHandle mappedLocalHandle) + { + MapType = mapType; + Scene = scene; + ScenePresent = isScenePresent; + SceneName = isScenePresent ? scene.name : "Not Present"; + + m_ServerHandle = serverHandle; + m_MappedLocalHandle = mappedLocalHandle; + m_LocalHandle = new NetworkSceneHandle(scene.handle); + +#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE + ServerSceneHandle = serverHandle; + MappedLocalSceneHandle = mappedLocalHandle; + LocalSceneHandle = scene.handle; +#endif + + +#pragma warning disable CS0618 // Type or member is obsolete +#if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG + ServerHandle = (int)Server.GetRawData(); + MappedLocalHandle = (int)MappedLocal.GetRawData(); + LocalHandle = (int)Local.GetRawData(); +#else + ServerHandle = m_ServerHandle.GetRawData(); + MappedLocalHandle = m_MappedLocalHandle.GetRawData(); + LocalHandle = m_LocalHandle.GetRawData(); +#endif +#pragma warning restore CS0618 // Type or member is obsolete + } + + /// + public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter + { + serializer.SerializeValue(ref MapType); + serializer.SerializeValue(ref ScenePresent); + if (serializer.IsReader) + { + SceneName = "Not Present"; + } + if (ScenePresent) + { + serializer.SerializeValue(ref SceneName); +#pragma warning disable CS0618 // Type or member is obsolete + serializer.SerializeValue(ref LocalHandle); + } + serializer.SerializeValue(ref ServerHandle); + serializer.SerializeValue(ref MappedLocalHandle); +#pragma warning restore CS0618 // Type or member is obsolete + + +#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE + // Ensure the SceneHandles are valid to be serialized + if (serializer.IsWriter) + { + if (m_LocalHandle.IsEmpty() && LocalSceneHandle != SceneHandle.None) + { + m_LocalHandle = LocalSceneHandle; + } + if (m_ServerHandle.IsEmpty() && ServerSceneHandle != SceneHandle.None) + { + m_ServerHandle = ServerSceneHandle; + } + if (m_MappedLocalHandle.IsEmpty() && MappedLocalSceneHandle != SceneHandle.None) + { + m_MappedLocalHandle = MappedLocalSceneHandle; + } + } + + // Serialize the INetworkSerializable representations + serializer.SerializeValue(ref m_LocalHandle); + serializer.SerializeValue(ref m_ServerHandle); + serializer.SerializeValue(ref m_MappedLocalHandle); + + // If we're reading, convert back into the raw SceneHandle + if (serializer.IsReader) + { + ServerSceneHandle = m_ServerHandle; + ServerSceneHandle = m_LocalHandle; + ServerSceneHandle = m_MappedLocalHandle; + } +#endif + } + } +} diff --git a/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs.meta b/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs.meta new file mode 100644 index 0000000000..970ade1cbc --- /dev/null +++ b/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0df5a20fcb4a4cf0b9959485cee438c5 +timeCreated: 1761147915 \ No newline at end of file From 2ff8ce8dc27e5d18b3f154b660d698efcaa76aba Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 22 Oct 2025 13:16:31 -0400 Subject: [PATCH 4/9] Put things back --- .../SceneManagement/NetworkSceneManager.cs | 185 +++++++++++++++++ .../Runtime/SceneManagement/SceneMap.cs | 193 ------------------ .../Runtime/SceneManagement/SceneMap.cs.meta | 3 - 3 files changed, 185 insertions(+), 196 deletions(-) delete mode 100644 com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs delete mode 100644 com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs.meta diff --git a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs index 3fd304857d..c66f02e710 100644 --- a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs @@ -3079,6 +3079,191 @@ private void ProcessDeferredCreateObjectMessages() DeferredObjectCreationList.Clear(); } + /// + /// The scene map type . + /// + public enum MapTypes + { + /// + /// Denotes the server to client scene map type. + /// + ServerToClient, + /// + /// Denotes the client to server scene map type. + /// + ClientToServer + } + + /// + /// Provides the status of a loaded scene + /// + public struct SceneMap : INetworkSerializable + { + /// + /// The scene mapping type . + /// + public MapTypes MapType; + /// + /// The struct of the scene mapped. + /// + public Scene Scene; + /// + /// When true, the scene is present. + /// + public bool ScenePresent; + /// + /// The name of the scene + /// + public string SceneName; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION + /// + /// The scene's server handle (a.k.a network scene handle) + /// + /// + /// This is deprecated in favor of ServerSceneHandle + /// + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> ServerSceneHandle")] +#else + /// + /// The scene's server handle (a.k.a network scene handle) + /// +#endif + public int ServerHandle; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION + /// + /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). + /// + /// + /// This is deprecated in favor of MappedLocalSceneHandle + /// + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> MappedLocalSceneHandle")] +#else + /// + /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). + /// +#endif + public int MappedLocalHandle; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION + /// + /// The local handle of the scene. + /// + /// + /// This is deprecated in favor of LocalSceneHandle + /// + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> LocalSceneHandle")] +#else + /// + /// The local handle of the scene. + /// +#endif + public int LocalHandle; + +#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE + /// + /// The scene's server handle (a.k.a network scene handle) + /// + public SceneHandle ServerSceneHandle; + /// + /// The mapped handled. This could be the ServerSceneHandle or LocalSceneHandle depending upon context (client or server). + /// + public SceneHandle MappedLocalSceneHandle; + /// + /// The local handle of the scene. + /// + public SceneHandle LocalSceneHandle; +#endif + + private NetworkSceneHandle m_ServerHandle; + private NetworkSceneHandle m_MappedLocalHandle; + private NetworkSceneHandle m_LocalHandle; + + internal SceneMap(MapTypes mapType, Scene scene, bool isScenePresent, NetworkSceneHandle serverHandle, NetworkSceneHandle mappedLocalHandle) + { + MapType = mapType; + Scene = scene; + ScenePresent = isScenePresent; + SceneName = isScenePresent ? scene.name : "Not Present"; + + m_ServerHandle = serverHandle; + m_MappedLocalHandle = mappedLocalHandle; + m_LocalHandle = new NetworkSceneHandle(scene.handle); + +#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE + ServerSceneHandle = serverHandle; + MappedLocalSceneHandle = mappedLocalHandle; + LocalSceneHandle = scene.handle; +#endif + +#pragma warning disable CS0618 // Type or member is obsolete +#if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG + ServerHandle = (int)m_ServerHandle.GetRawData(); + MappedLocalHandle = (int)m_MappedLocalHandle.GetRawData(); + LocalHandle = (int)m_LocalHandle.GetRawData(); +#else + ServerHandle = m_ServerHandle.GetRawData(); + MappedLocalHandle = m_MappedLocalHandle.GetRawData(); + LocalHandle = m_LocalHandle.GetRawData(); +#endif +#pragma warning restore CS0618 // Type or member is obsolete + } + + /// + public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter + { + serializer.SerializeValue(ref MapType); + serializer.SerializeValue(ref ScenePresent); + if (serializer.IsReader) + { + SceneName = "Not Present"; + } + if (ScenePresent) + { + serializer.SerializeValue(ref SceneName); +#pragma warning disable CS0618 // Type or member is obsolete + serializer.SerializeValue(ref LocalHandle); + } + serializer.SerializeValue(ref ServerHandle); + serializer.SerializeValue(ref MappedLocalHandle); +#pragma warning restore CS0618 // Type or member is obsolete + + +#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE + // Ensure the SceneHandles are valid to be serialized + if (serializer.IsWriter) + { + if (m_LocalHandle.IsEmpty() && LocalSceneHandle != SceneHandle.None) + { + m_LocalHandle = LocalSceneHandle; + } + if (m_ServerHandle.IsEmpty() && ServerSceneHandle != SceneHandle.None) + { + m_ServerHandle = ServerSceneHandle; + } + if (m_MappedLocalHandle.IsEmpty() && MappedLocalSceneHandle != SceneHandle.None) + { + m_MappedLocalHandle = MappedLocalSceneHandle; + } + } + + // Serialize the INetworkSerializable representations + serializer.SerializeValue(ref m_LocalHandle); + serializer.SerializeValue(ref m_ServerHandle); + serializer.SerializeValue(ref m_MappedLocalHandle); + + // If we're reading, convert back into the raw SceneHandle + if (serializer.IsReader) + { + ServerSceneHandle = m_ServerHandle; + ServerSceneHandle = m_LocalHandle; + ServerSceneHandle = m_MappedLocalHandle; + } +#endif + } + } + /// /// Returns the list of all scene mappings when scene management is enabled. /// diff --git a/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs b/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs deleted file mode 100644 index 0b9ac059a1..0000000000 --- a/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs +++ /dev/null @@ -1,193 +0,0 @@ -#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION -using System; -#endif -using UnityEngine.SceneManagement; - -namespace Unity.Netcode -{ - /// - /// The scene map type . - /// - public enum MapTypes - { - /// - /// Denotes the server to client scene map type. - /// - ServerToClient, - /// - /// Denotes the client to server scene map type. - /// - ClientToServer - } - - /// - /// Provides the status of a loaded scene - /// - public struct SceneMap : INetworkSerializable - { - /// - /// The scene mapping type . - /// - public MapTypes MapType; - /// - /// The struct of the scene mapped. - /// - public Scene Scene; - /// - /// When true, the scene is present. - /// - public bool ScenePresent; - /// - /// The name of the scene - /// - public string SceneName; - -#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION - /// - /// The scene's server handle (a.k.a network scene handle) - /// - /// - /// This is deprecated in favor of ServerSceneHandle - /// - [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> ServerSceneHandle")] -#else - /// - /// The scene's server handle (a.k.a network scene handle) - /// -#endif - public int ServerHandle; - -#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION - /// - /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). - /// - /// - /// This is deprecated in favor of MappedLocalSceneHandle - /// - [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> MappedLocalSceneHandle")] -#else - /// - /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). - /// -#endif - public int MappedLocalHandle; - -#if SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION - /// - /// The local handle of the scene. - /// - /// - /// This is deprecated in favor of LocalSceneHandle - /// - [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> LocalSceneHandle")] -#else - /// - /// The local handle of the scene. - /// -#endif - public int LocalHandle; - -#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE - /// - /// The scene's server handle (a.k.a network scene handle) - /// - public SceneHandle ServerSceneHandle; - /// - /// The mapped handled. This could be the ServerSceneHandle or LocalSceneHandle depending upon context (client or server). - /// - public SceneHandle MappedLocalSceneHandle; - /// - /// The local handle of the scene. - /// - public SceneHandle LocalSceneHandle; -#endif - - private NetworkSceneHandle m_ServerHandle; - private NetworkSceneHandle m_MappedLocalHandle; - private NetworkSceneHandle m_LocalHandle; - - internal SceneMap(MapTypes mapType, Scene scene, bool isScenePresent, NetworkSceneHandle serverHandle, NetworkSceneHandle mappedLocalHandle) - { - MapType = mapType; - Scene = scene; - ScenePresent = isScenePresent; - SceneName = isScenePresent ? scene.name : "Not Present"; - - m_ServerHandle = serverHandle; - m_MappedLocalHandle = mappedLocalHandle; - m_LocalHandle = new NetworkSceneHandle(scene.handle); - -#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE - ServerSceneHandle = serverHandle; - MappedLocalSceneHandle = mappedLocalHandle; - LocalSceneHandle = scene.handle; -#endif - - -#pragma warning disable CS0618 // Type or member is obsolete -#if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG - ServerHandle = (int)Server.GetRawData(); - MappedLocalHandle = (int)MappedLocal.GetRawData(); - LocalHandle = (int)Local.GetRawData(); -#else - ServerHandle = m_ServerHandle.GetRawData(); - MappedLocalHandle = m_MappedLocalHandle.GetRawData(); - LocalHandle = m_LocalHandle.GetRawData(); -#endif -#pragma warning restore CS0618 // Type or member is obsolete - } - - /// - public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter - { - serializer.SerializeValue(ref MapType); - serializer.SerializeValue(ref ScenePresent); - if (serializer.IsReader) - { - SceneName = "Not Present"; - } - if (ScenePresent) - { - serializer.SerializeValue(ref SceneName); -#pragma warning disable CS0618 // Type or member is obsolete - serializer.SerializeValue(ref LocalHandle); - } - serializer.SerializeValue(ref ServerHandle); - serializer.SerializeValue(ref MappedLocalHandle); -#pragma warning restore CS0618 // Type or member is obsolete - - -#if SCENE_MANAGEMENT_SCENE_HANDLE_AVAILABLE - // Ensure the SceneHandles are valid to be serialized - if (serializer.IsWriter) - { - if (m_LocalHandle.IsEmpty() && LocalSceneHandle != SceneHandle.None) - { - m_LocalHandle = LocalSceneHandle; - } - if (m_ServerHandle.IsEmpty() && ServerSceneHandle != SceneHandle.None) - { - m_ServerHandle = ServerSceneHandle; - } - if (m_MappedLocalHandle.IsEmpty() && MappedLocalSceneHandle != SceneHandle.None) - { - m_MappedLocalHandle = MappedLocalSceneHandle; - } - } - - // Serialize the INetworkSerializable representations - serializer.SerializeValue(ref m_LocalHandle); - serializer.SerializeValue(ref m_ServerHandle); - serializer.SerializeValue(ref m_MappedLocalHandle); - - // If we're reading, convert back into the raw SceneHandle - if (serializer.IsReader) - { - ServerSceneHandle = m_ServerHandle; - ServerSceneHandle = m_LocalHandle; - ServerSceneHandle = m_MappedLocalHandle; - } -#endif - } - } -} diff --git a/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs.meta b/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs.meta deleted file mode 100644 index 970ade1cbc..0000000000 --- a/com.unity.netcode.gameobjects/Runtime/SceneManagement/SceneMap.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0df5a20fcb4a4cf0b9959485cee438c5 -timeCreated: 1761147915 \ No newline at end of file From 11641b411d3f93f3af1d3985529031fdbb8cf7c1 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 22 Oct 2025 13:41:18 -0400 Subject: [PATCH 5/9] Fix yamato trigger --- .yamato/project.metafile | 1 + 1 file changed, 1 insertion(+) diff --git a/.yamato/project.metafile b/.yamato/project.metafile index bc3de36f73..13f7801cf7 100644 --- a/.yamato/project.metafile +++ b/.yamato/project.metafile @@ -162,6 +162,7 @@ validation_editors: - 6000.0 - 6000.2 - 6000.3 + - 6000.4 - trunk minimal: - 6000.0 From d548a632039b7b69056564d10b2b64e8e87a3af4 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 22 Oct 2025 16:23:15 -0400 Subject: [PATCH 6/9] Fix tests --- .../SceneManagement/NetworkSceneHandle.cs | 2 +- .../Serialization/NetworkSceneHandleTests.cs | 47 +++++++++++++++++++ .../NetworkSceneHandleTests.cs.meta | 3 ++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs create mode 100644 com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs.meta diff --git a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneHandle.cs b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneHandle.cs index 9a2053c2ed..e544eb1f24 100644 --- a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneHandle.cs +++ b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneHandle.cs @@ -36,7 +36,7 @@ public void NetworkSerialize(BufferSerializer serializer) where T : IReade var reader = serializer.GetFastBufferReader(); // DANGO-TODO Rust needs to be updated to either handle this ulong or to remove the scene store. #if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG - reader.ReadValue(out ulong rawData); + reader.ReadValueSafe(out ulong rawData); m_Handle = SceneHandle.FromRawData(rawData); #elif SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION reader.ReadValueSafe(out int rawData); diff --git a/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs b/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs new file mode 100644 index 0000000000..4d366df89d --- /dev/null +++ b/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs @@ -0,0 +1,47 @@ +using NUnit.Framework; +using Unity.Collections; + +namespace Unity.Netcode.EditorTests +{ + internal class NetworkSceneHandleTests + { + [Test] + public void NetworkSceneHandleSerializationTest() + { + var handle = new NetworkSceneHandle(1234, true); + + using var writer = new FastBufferWriter(sizeof(ulong), Allocator.Temp); + Assert.That(writer.Position, Is.EqualTo(0), "Writer position should be zero"); + + writer.WriteValue(handle); + + Assert.That(writer.Position, Is.EqualTo(sizeof(ulong)), "Writer position should not be beyond size"); + + var reader = new FastBufferReader(writer, Allocator.Temp); + Assert.That(reader.Position, Is.EqualTo(0), "Reader position should be zero"); + reader.ReadValue(out NetworkSceneHandle deserializedHandle); + Assert.That(writer.Position, Is.EqualTo(sizeof(ulong)), "Reader position should not be beyond size"); + + Assert.AreEqual(handle, deserializedHandle); + + // Now serialize a list of SceneHandles + var handles = new NetworkSceneHandle[] { handle, new NetworkSceneHandle(4567, true), new NetworkSceneHandle(7890, true) }; + + using var listWriter = new FastBufferWriter(1024, Allocator.Temp); + + Assert.That(listWriter.Position, Is.EqualTo(0), "Writer position should be zero"); + + listWriter.WriteValue(handles); + + var expectedSize = sizeof(int) + (sizeof(ulong) * handles.Length); + Assert.That(listWriter.Position, Is.EqualTo(expectedSize), "Writer position should not be beyond size"); + + var listReader = new FastBufferReader(listWriter, Allocator.Temp); + Assert.That(listReader.Position, Is.EqualTo(0), "Reader position should be zero"); + listReader.ReadValue(out NetworkSceneHandle[] deserializedHandleList); + Assert.That(listReader.Position, Is.EqualTo(expectedSize), "Reader position should not be beyond expected size"); + + Assert.AreEqual(handles, deserializedHandleList); + } + } +} diff --git a/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs.meta b/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs.meta new file mode 100644 index 0000000000..321da91062 --- /dev/null +++ b/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3c489c7005c84ba4a42d90c28a3d0536 +timeCreated: 1761163221 \ No newline at end of file From aa3a1213b256fd7bf84d89511690d2d72706dcfc Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Wed, 22 Oct 2025 17:44:42 -0500 Subject: [PATCH 7/9] test-fix Fixing issue with the scene handle test and running in the "in-between" 6.4 version of Unity. --- .../Serialization/NetworkSceneHandleTests.cs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs b/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs index 4d366df89d..731f37dfad 100644 --- a/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs @@ -14,13 +14,20 @@ public void NetworkSceneHandleSerializationTest() Assert.That(writer.Position, Is.EqualTo(0), "Writer position should be zero"); writer.WriteValue(handle); - - Assert.That(writer.Position, Is.EqualTo(sizeof(ulong)), "Writer position should not be beyond size"); +#if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG + Assert.That(writer.Position, Is.EqualTo(sizeof(ulong)), $"Writer position should not be beyond size! Expected: {sizeof(ulong)} Actual: {writer.Position}"); +#else + Assert.That(writer.Position, Is.EqualTo(sizeof(int)), $"Writer position should not be beyond size! Expected: {sizeof(int)} Actual: {writer.Position}"); +#endif var reader = new FastBufferReader(writer, Allocator.Temp); Assert.That(reader.Position, Is.EqualTo(0), "Reader position should be zero"); reader.ReadValue(out NetworkSceneHandle deserializedHandle); - Assert.That(writer.Position, Is.EqualTo(sizeof(ulong)), "Reader position should not be beyond size"); +#if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG + Assert.That(reader.Position, Is.EqualTo(sizeof(ulong)), $"Reader position should not be beyond size! Expected: {sizeof(ulong)} Actual: {reader.Position}"); +#else + Assert.That(reader.Position, Is.EqualTo(sizeof(int)), $"Reader position should not be beyond size! Expected: {sizeof(int)} Actual: {reader.Position}"); +#endif Assert.AreEqual(handle, deserializedHandle); @@ -32,14 +39,17 @@ public void NetworkSceneHandleSerializationTest() Assert.That(listWriter.Position, Is.EqualTo(0), "Writer position should be zero"); listWriter.WriteValue(handles); - +#if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG var expectedSize = sizeof(int) + (sizeof(ulong) * handles.Length); - Assert.That(listWriter.Position, Is.EqualTo(expectedSize), "Writer position should not be beyond size"); +#else + var expectedSize = sizeof(int) + (sizeof(int) * handles.Length); +#endif + Assert.That(listWriter.Position, Is.EqualTo(expectedSize), $"Writer position should not be beyond size! Expected: {expectedSize} Actual: {listWriter.Position}"); var listReader = new FastBufferReader(listWriter, Allocator.Temp); Assert.That(listReader.Position, Is.EqualTo(0), "Reader position should be zero"); listReader.ReadValue(out NetworkSceneHandle[] deserializedHandleList); - Assert.That(listReader.Position, Is.EqualTo(expectedSize), "Reader position should not be beyond expected size"); + Assert.That(listReader.Position, Is.EqualTo(expectedSize), $"Reader position should not be beyond expected size! Expected: {expectedSize} Actual: {listReader.Position}"); Assert.AreEqual(handles, deserializedHandleList); } From 227cf6c5461a6cd435b4dff11864ea4878572666 Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Wed, 22 Oct 2025 19:49:27 -0500 Subject: [PATCH 8/9] test - fix For reals this time. Adding the defines for SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION and SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG to the editor tests assembly. --- .../Editor/Serialization/NetworkSceneHandleTests.cs | 8 ++++---- .../Tests/Editor/Unity.Netcode.Editor.Tests.asmdef | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs b/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs index 731f37dfad..8be50e5530 100644 --- a/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Editor/Serialization/NetworkSceneHandleTests.cs @@ -13,7 +13,7 @@ public void NetworkSceneHandleSerializationTest() using var writer = new FastBufferWriter(sizeof(ulong), Allocator.Temp); Assert.That(writer.Position, Is.EqualTo(0), "Writer position should be zero"); - writer.WriteValue(handle); + writer.WriteNetworkSerializable(handle); #if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG Assert.That(writer.Position, Is.EqualTo(sizeof(ulong)), $"Writer position should not be beyond size! Expected: {sizeof(ulong)} Actual: {writer.Position}"); #else @@ -22,7 +22,7 @@ public void NetworkSceneHandleSerializationTest() var reader = new FastBufferReader(writer, Allocator.Temp); Assert.That(reader.Position, Is.EqualTo(0), "Reader position should be zero"); - reader.ReadValue(out NetworkSceneHandle deserializedHandle); + reader.ReadNetworkSerializable(out NetworkSceneHandle deserializedHandle); #if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG Assert.That(reader.Position, Is.EqualTo(sizeof(ulong)), $"Reader position should not be beyond size! Expected: {sizeof(ulong)} Actual: {reader.Position}"); #else @@ -38,7 +38,7 @@ public void NetworkSceneHandleSerializationTest() Assert.That(listWriter.Position, Is.EqualTo(0), "Writer position should be zero"); - listWriter.WriteValue(handles); + listWriter.WriteNetworkSerializable(handles); #if SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG var expectedSize = sizeof(int) + (sizeof(ulong) * handles.Length); #else @@ -48,7 +48,7 @@ public void NetworkSceneHandleSerializationTest() var listReader = new FastBufferReader(listWriter, Allocator.Temp); Assert.That(listReader.Position, Is.EqualTo(0), "Reader position should be zero"); - listReader.ReadValue(out NetworkSceneHandle[] deserializedHandleList); + listReader.ReadNetworkSerializable(out NetworkSceneHandle[] deserializedHandleList); Assert.That(listReader.Position, Is.EqualTo(expectedSize), $"Reader position should not be beyond expected size! Expected: {expectedSize} Actual: {listReader.Position}"); Assert.AreEqual(handles, deserializedHandleList); diff --git a/com.unity.netcode.gameobjects/Tests/Editor/Unity.Netcode.Editor.Tests.asmdef b/com.unity.netcode.gameobjects/Tests/Editor/Unity.Netcode.Editor.Tests.asmdef index f45952ca0e..c213a6de64 100644 --- a/com.unity.netcode.gameobjects/Tests/Editor/Unity.Netcode.Editor.Tests.asmdef +++ b/com.unity.netcode.gameobjects/Tests/Editor/Unity.Netcode.Editor.Tests.asmdef @@ -43,6 +43,16 @@ "name": "Unity", "expression": "6000.1.0a1", "define": "HOSTNAME_RESOLUTION_AVAILABLE" + }, + { + "name": "Unity", + "expression": "6000.4.0a3", + "define": "SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION" + }, + { + "name": "Unity", + "expression": "6000.5.0a1", + "define": "SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG" } ], "noEngineReferences": false From 015c47e40a86bc5d2f1856f218ce27f509c27bc7 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 22 Oct 2025 21:35:30 -0400 Subject: [PATCH 9/9] Remove UnityUpgradable from obsolete messages --- .../Runtime/SceneManagement/NetworkSceneManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs index c66f02e710..6ab3e930f2 100644 --- a/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs @@ -3123,7 +3123,7 @@ public struct SceneMap : INetworkSerializable /// /// This is deprecated in favor of ServerSceneHandle /// - [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> ServerSceneHandle")] + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead.")] #else /// /// The scene's server handle (a.k.a network scene handle) @@ -3138,7 +3138,7 @@ public struct SceneMap : INetworkSerializable /// /// This is deprecated in favor of MappedLocalSceneHandle /// - [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> MappedLocalSceneHandle")] + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead.")] #else /// /// The mapped handled. This could be the ServerHandle or LocalHandle depending upon context (client or server). @@ -3153,7 +3153,7 @@ public struct SceneMap : INetworkSerializable /// /// This is deprecated in favor of LocalSceneHandle /// - [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead. (UnityUpgradable) -> LocalSceneHandle")] + [Obsolete("Int representation of a SceneHandle is deprecated, please use SceneHandle instead.")] #else /// /// The local handle of the scene.