diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index 0d8fb3a2fb..06ebf2c108 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -18,6 +18,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Deprecated +- Deprecated a number of methods that were no longer valid or being used. (#3987) ### Removed diff --git a/com.unity.netcode.gameobjects/Editor/CodeGen/RuntimeAccessModifiersILPP.cs b/com.unity.netcode.gameobjects/Editor/CodeGen/RuntimeAccessModifiersILPP.cs index 57295be52e..ffea9115b7 100644 --- a/com.unity.netcode.gameobjects/Editor/CodeGen/RuntimeAccessModifiersILPP.cs +++ b/com.unity.netcode.gameobjects/Editor/CodeGen/RuntimeAccessModifiersILPP.cs @@ -97,17 +97,23 @@ private void ProcessNetworkManager(TypeDefinition typeDefinition, string[] assem { foreach (var fieldDefinition in typeDefinition.Fields) { +#pragma warning disable CS0618 // Type or member is obsolete if (fieldDefinition.Name == nameof(NetworkManager.__rpc_func_table)) +#pragma warning restore CS0618 // Type or member is obsolete { fieldDefinition.IsPublic = true; } +#pragma warning disable CS0618 // Type or member is obsolete if (fieldDefinition.Name == nameof(NetworkManager.RpcReceiveHandler)) +#pragma warning restore CS0618 // Type or member is obsolete { fieldDefinition.IsPublic = true; } +#pragma warning disable CS0618 // Type or member is obsolete if (fieldDefinition.Name == nameof(NetworkManager.__rpc_name_table)) +#pragma warning restore CS0618 // Type or member is obsolete { fieldDefinition.IsPublic = true; } @@ -115,7 +121,9 @@ private void ProcessNetworkManager(TypeDefinition typeDefinition, string[] assem foreach (var nestedTypeDefinition in typeDefinition.NestedTypes) { +#pragma warning disable CS0618 // Type or member is obsolete if (nestedTypeDefinition.Name == nameof(NetworkManager.RpcReceiveHandler)) +#pragma warning restore CS0618 // Type or member is obsolete { nestedTypeDefinition.IsNestedPublic = true; } diff --git a/com.unity.netcode.gameobjects/Editor/NetworkBehaviourEditor.cs b/com.unity.netcode.gameobjects/Editor/NetworkBehaviourEditor.cs index 1312ff69e6..c2ce7da626 100644 --- a/com.unity.netcode.gameobjects/Editor/NetworkBehaviourEditor.cs +++ b/com.unity.netcode.gameobjects/Editor/NetworkBehaviourEditor.cs @@ -322,18 +322,13 @@ private void OnEnable() } /// - /// Recursively finds the root parent of a + /// Obsolete method to find root parent of a . + /// Use instead. /// /// The current we are inspecting for a parent /// the root parent for the first passed into the method - public static Transform GetRootParentTransform(Transform transform) - { - if (transform.parent == null || transform.parent == transform) - { - return transform; - } - return GetRootParentTransform(transform.parent); - } + [Obsolete("Use transform.root instead")] + public static Transform GetRootParentTransform(Transform transform) => transform.root; /// /// Used to determine if a GameObject has one or more NetworkBehaviours but @@ -358,7 +353,7 @@ public static void CheckForNetworkObject(GameObject gameObject, bool networkObje } // Now get the root parent transform to the current GameObject (or itself) - var rootTransform = GetRootParentTransform(gameObject.transform); + var rootTransform = gameObject.transform.root; if (!rootTransform.TryGetComponent(out var networkManager)) { networkManager = rootTransform.GetComponentInChildren(); diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs index 8fc97dd84e..55fdd6dbf8 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs @@ -44,12 +44,15 @@ public class NetworkManager : MonoBehaviour, INetworkUpdateSystem #pragma warning disable IDE1006 // disable naming rule violation check // RuntimeAccessModifiersILPP will make this `public` + [Obsolete("This field is no longer used and will be removed in a future version.")] internal delegate void RpcReceiveHandler(NetworkBehaviour behaviour, FastBufferReader reader, __RpcParams parameters); // RuntimeAccessModifiersILPP will make this `public` + [Obsolete("This field is no longer used and will be removed in a future version.")] internal static readonly Dictionary __rpc_func_table = new Dictionary(); // RuntimeAccessModifiersILPP will make this `public` (legacy table should be removed in v3.x.x) + [Obsolete("This field is no longer used and will be removed in a future version.")] internal static readonly Dictionary __rpc_name_table = new Dictionary(); #pragma warning restore IDE1006 // restore naming rule violation check diff --git a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs index aafeeb2ab4..9c0cb4bd83 100644 --- a/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs +++ b/com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs @@ -683,14 +683,8 @@ private void HandleAddListEvent(NetworkListEvent listEvent) /// /// This method should not be used. It is left over from a previous interface /// - public int LastModifiedTick - { - get - { - // todo: implement proper network tick for NetworkList - return NetworkTickSystem.NoTick; - } - } + [Obsolete("This property is no longer used and will be removed in a future version.")] + public int LastModifiedTick => NetworkTickSystem.NoTick; /// /// Overridden implementation. diff --git a/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs b/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs index 52e891f8e1..7a2f45b1d1 100644 --- a/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs @@ -448,6 +448,7 @@ private bool TryGetNetworkClient(ulong clientId, out NetworkClient networkClient /// /// not used /// not used + [Obsolete("This method is no longer used and will be removed in a future version.")] protected virtual void InternalOnOwnershipChanged(ulong perviousOwner, ulong newOwner) { diff --git a/testproject/Assets/Tests/Manual/NestedNetworkTransforms/ChildMover.cs b/testproject/Assets/Tests/Manual/NestedNetworkTransforms/ChildMover.cs index f731d6fe95..efaceb4a38 100644 --- a/testproject/Assets/Tests/Manual/NestedNetworkTransforms/ChildMover.cs +++ b/testproject/Assets/Tests/Manual/NestedNetworkTransforms/ChildMover.cs @@ -45,20 +45,11 @@ public void PlayerIsMoving(float movementDirection) } } - private Transform GetRootParentTransform(Transform transform) - { - if (transform.parent != null) - { - return GetRootParentTransform(transform.parent); - } - return transform; - } - protected override void OnNetworkPostSpawn() { if (CanCommitToTransform) { - m_RootParentTransform = GetRootParentTransform(transform); + m_RootParentTransform = transform.root; if (RandomizeScale) { transform.localScale = transform.localScale * Random.Range(0.5f, 1.5f); diff --git a/testproject/Assets/Tests/Runtime/RpcTestsAutomated.cs b/testproject/Assets/Tests/Runtime/RpcTestsAutomated.cs index 228bfbfdd5..1332aed20a 100644 --- a/testproject/Assets/Tests/Runtime/RpcTestsAutomated.cs +++ b/testproject/Assets/Tests/Runtime/RpcTestsAutomated.cs @@ -6,7 +6,6 @@ using Unity.Netcode.TestHelpers.Runtime; using UnityEngine; using UnityEngine.TestTools; -using Debug = UnityEngine.Debug; namespace TestProject.RuntimeTests { @@ -120,16 +119,16 @@ private IEnumerator AutomatedRpcTestsHandler(int numClients) Assert.IsFalse(m_TimedOut); // Log the output for visual confirmation (Acceptance Test for this test) that all RPC test types (tracked by counters) executed multiple times - Debug.Log("Final Host-Server Status Info:"); - Debug.Log(serverRpcTests.GetCurrentServerStatusInfo()); + VerboseDebug("Final Host-Server Status Info:"); + VerboseDebug(serverRpcTests.GetCurrentServerStatusInfo()); foreach (var rpcClientSideTest in clientRpcQueueManualTestInstsances) { - Debug.Log($"Final Client {rpcClientSideTest.NetworkManager.LocalClientId} Status Info:"); - Debug.Log(rpcClientSideTest.GetCurrentClientStatusInfo()); + VerboseDebug($"Final Client {rpcClientSideTest.NetworkManager.LocalClientId} Status Info:"); + VerboseDebug(rpcClientSideTest.GetCurrentClientStatusInfo()); } - Debug.Log($"Total frames updated = {Time.frameCount - startFrameCount} within {Time.realtimeSinceStartup - startTime} seconds."); + VerboseDebug($"Total frames updated = {Time.frameCount - startFrameCount} within {Time.realtimeSinceStartup - startTime} seconds."); } } }