Skip to content

Commit ea56a62

Browse files
authored
Merge branch 'develop-2.0.0' into chore/fast-enter-playmode
2 parents 9dc2b33 + 75c36f4 commit ea56a62

8 files changed

Lines changed: 26 additions & 34 deletions

File tree

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1919

2020
### Deprecated
2121

22+
- Deprecated a number of methods that were no longer valid or being used. (#3987)
2223

2324
### Removed
2425

com.unity.netcode.gameobjects/Editor/CodeGen/RuntimeAccessModifiersILPP.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,33 @@ private void ProcessNetworkManager(TypeDefinition typeDefinition, string[] assem
9797
{
9898
foreach (var fieldDefinition in typeDefinition.Fields)
9999
{
100+
#pragma warning disable CS0618 // Type or member is obsolete
100101
if (fieldDefinition.Name == nameof(NetworkManager.__rpc_func_table))
102+
#pragma warning restore CS0618 // Type or member is obsolete
101103
{
102104
fieldDefinition.IsPublic = true;
103105
}
104106

107+
#pragma warning disable CS0618 // Type or member is obsolete
105108
if (fieldDefinition.Name == nameof(NetworkManager.RpcReceiveHandler))
109+
#pragma warning restore CS0618 // Type or member is obsolete
106110
{
107111
fieldDefinition.IsPublic = true;
108112
}
109113

114+
#pragma warning disable CS0618 // Type or member is obsolete
110115
if (fieldDefinition.Name == nameof(NetworkManager.__rpc_name_table))
116+
#pragma warning restore CS0618 // Type or member is obsolete
111117
{
112118
fieldDefinition.IsPublic = true;
113119
}
114120
}
115121

116122
foreach (var nestedTypeDefinition in typeDefinition.NestedTypes)
117123
{
124+
#pragma warning disable CS0618 // Type or member is obsolete
118125
if (nestedTypeDefinition.Name == nameof(NetworkManager.RpcReceiveHandler))
126+
#pragma warning restore CS0618 // Type or member is obsolete
119127
{
120128
nestedTypeDefinition.IsNestedPublic = true;
121129
}

com.unity.netcode.gameobjects/Editor/NetworkBehaviourEditor.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -322,18 +322,13 @@ private void OnEnable()
322322
}
323323

324324
/// <summary>
325-
/// Recursively finds the root parent of a <see cref="Transform"/>
325+
/// Obsolete method to find root parent of a <see cref="Transform"/>.
326+
/// Use <see cref="Transform.root"/> instead.
326327
/// </summary>
327328
/// <param name="transform">The current <see cref="Transform"/> we are inspecting for a parent</param>
328329
/// <returns>the root parent for the first <see cref="Transform"/> passed into the method</returns>
329-
public static Transform GetRootParentTransform(Transform transform)
330-
{
331-
if (transform.parent == null || transform.parent == transform)
332-
{
333-
return transform;
334-
}
335-
return GetRootParentTransform(transform.parent);
336-
}
330+
[Obsolete("Use transform.root instead")]
331+
public static Transform GetRootParentTransform(Transform transform) => transform.root;
337332

338333
/// <summary>
339334
/// Used to determine if a GameObject has one or more NetworkBehaviours but
@@ -358,7 +353,7 @@ public static void CheckForNetworkObject(GameObject gameObject, bool networkObje
358353
}
359354

360355
// Now get the root parent transform to the current GameObject (or itself)
361-
var rootTransform = GetRootParentTransform(gameObject.transform);
356+
var rootTransform = gameObject.transform.root;
362357
if (!rootTransform.TryGetComponent<NetworkManager>(out var networkManager))
363358
{
364359
networkManager = rootTransform.GetComponentInChildren<NetworkManager>();

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ private static void ResetStaticsOnLoad()
5757
#pragma warning disable IDE1006 // disable naming rule violation check
5858

5959
// RuntimeAccessModifiersILPP will make this `public`
60+
[Obsolete("This field is no longer used and will be removed in a future version.")]
6061
internal delegate void RpcReceiveHandler(NetworkBehaviour behaviour, FastBufferReader reader, __RpcParams parameters);
6162

6263
// RuntimeAccessModifiersILPP will make this `public`
64+
[Obsolete("This field is no longer used and will be removed in a future version.")]
6365
internal static readonly Dictionary<uint, RpcReceiveHandler> __rpc_func_table = new Dictionary<uint, RpcReceiveHandler>();
6466

6567
// RuntimeAccessModifiersILPP will make this `public` (legacy table should be removed in v3.x.x)
68+
[Obsolete("This field is no longer used and will be removed in a future version.")]
6669
internal static readonly Dictionary<uint, string> __rpc_name_table = new Dictionary<uint, string>();
6770

6871
#pragma warning restore IDE1006 // restore naming rule violation check

com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -683,14 +683,8 @@ private void HandleAddListEvent(NetworkListEvent<T> listEvent)
683683
/// <summary>
684684
/// This method should not be used. It is left over from a previous interface
685685
/// </summary>
686-
public int LastModifiedTick
687-
{
688-
get
689-
{
690-
// todo: implement proper network tick for NetworkList
691-
return NetworkTickSystem.NoTick;
692-
}
693-
}
686+
[Obsolete("This property is no longer used and will be removed in a future version.")]
687+
public int LastModifiedTick => NetworkTickSystem.NoTick;
694688

695689
/// <summary>
696690
/// Overridden <see cref="IDisposable"/> implementation.

com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ private bool TryGetNetworkClient(ulong clientId, out NetworkClient networkClient
448448
/// </summary>
449449
/// <param name="perviousOwner">not used</param>
450450
/// <param name="newOwner">not used</param>
451+
[Obsolete("This method is no longer used and will be removed in a future version.")]
451452
protected virtual void InternalOnOwnershipChanged(ulong perviousOwner, ulong newOwner)
452453
{
453454

testproject/Assets/Tests/Manual/NestedNetworkTransforms/ChildMover.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,11 @@ public void PlayerIsMoving(float movementDirection)
4545
}
4646
}
4747

48-
private Transform GetRootParentTransform(Transform transform)
49-
{
50-
if (transform.parent != null)
51-
{
52-
return GetRootParentTransform(transform.parent);
53-
}
54-
return transform;
55-
}
56-
5748
protected override void OnNetworkPostSpawn()
5849
{
5950
if (CanCommitToTransform)
6051
{
61-
m_RootParentTransform = GetRootParentTransform(transform);
52+
m_RootParentTransform = transform.root;
6253
if (RandomizeScale)
6354
{
6455
transform.localScale = transform.localScale * Random.Range(0.5f, 1.5f);

testproject/Assets/Tests/Runtime/RpcTestsAutomated.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Unity.Netcode.TestHelpers.Runtime;
77
using UnityEngine;
88
using UnityEngine.TestTools;
9-
using Debug = UnityEngine.Debug;
109

1110
namespace TestProject.RuntimeTests
1211
{
@@ -120,16 +119,16 @@ private IEnumerator AutomatedRpcTestsHandler(int numClients)
120119
Assert.IsFalse(m_TimedOut);
121120

122121
// Log the output for visual confirmation (Acceptance Test for this test) that all RPC test types (tracked by counters) executed multiple times
123-
Debug.Log("Final Host-Server Status Info:");
124-
Debug.Log(serverRpcTests.GetCurrentServerStatusInfo());
122+
VerboseDebug("Final Host-Server Status Info:");
123+
VerboseDebug(serverRpcTests.GetCurrentServerStatusInfo());
125124

126125
foreach (var rpcClientSideTest in clientRpcQueueManualTestInstsances)
127126
{
128-
Debug.Log($"Final Client {rpcClientSideTest.NetworkManager.LocalClientId} Status Info:");
129-
Debug.Log(rpcClientSideTest.GetCurrentClientStatusInfo());
127+
VerboseDebug($"Final Client {rpcClientSideTest.NetworkManager.LocalClientId} Status Info:");
128+
VerboseDebug(rpcClientSideTest.GetCurrentClientStatusInfo());
130129
}
131130

132-
Debug.Log($"Total frames updated = {Time.frameCount - startFrameCount} within {Time.realtimeSinceStartup - startTime} seconds.");
131+
VerboseDebug($"Total frames updated = {Time.frameCount - startFrameCount} within {Time.realtimeSinceStartup - startTime} seconds.");
133132
}
134133
}
135134
}

0 commit comments

Comments
 (0)