Skip to content

Commit f6f815c

Browse files
chore!: migrate components to runtime assembly [MTT-8472] (#2914)
* update Migrated components to runtime. Added some low hanging fruit updates to NetworkTransform and NetworkTransformMessage to help optimize cpu consumption and reduce GC allocations. Disabled the ticks ago since RTT seems to only update when a client sends packets. * test Made adjustments to tests and testproject assets. * fix Fixing scenario where m_UseRigidbodyForMotion is not defined and was being used to register for updates. Removed some whitespaces. Wrapping all fixed update related methods and properties in NetworkManager within #if COM_UNITY_MODULES_PHYSICS. Adjusting the ILPP for NetworkBehaviour to scan the Runtime assembly too. Adjusting the early exit for lack of observer count to only happen in DA mode. * test fix Sometimes the ClientDisconnectMultipleClients can exceed more than 2s (but seemingly less than 5) before receiving all events. Reverting the OnUpdate change to TransformInterpolationObject's back to Update as both instances need to update regularly for this test. Fixing issue with unreliable delta full state synchronization.
1 parent be8a02a commit f6f815c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+462
-375
lines changed

com.unity.netcode.gameobjects/Components/AssemblyInfo.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

com.unity.netcode.gameobjects/Components/AssemblyInfo.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

com.unity.netcode.gameobjects/Components/Messages/NetworkTransformMessage.cs

Lines changed: 0 additions & 205 deletions
This file was deleted.

com.unity.netcode.gameobjects/Components/com.unity.netcode.components.asmdef

Lines changed: 0 additions & 27 deletions
This file was deleted.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ internal sealed class NetworkBehaviourILPP : ILPPInterface
2727

2828
public override ILPPInterface GetInstance() => this;
2929

30-
public override bool WillProcess(ICompiledAssembly compiledAssembly) => compiledAssembly.References.Any(filePath => Path.GetFileNameWithoutExtension(filePath) == CodeGenHelpers.RuntimeAssemblyName);
30+
public override bool WillProcess(ICompiledAssembly compiledAssembly) => compiledAssembly.Name == CodeGenHelpers.RuntimeAssemblyName ||
31+
compiledAssembly.References.Any(filePath => Path.GetFileNameWithoutExtension(filePath) == CodeGenHelpers.RuntimeAssemblyName);
3132

3233
private readonly List<DiagnosticMessage> m_Diagnostics = new List<DiagnosticMessage>();
3334

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public class NetworkManagerEditor : UnityEditor.Editor
4343
private SerializedProperty m_LoadSceneTimeOutProperty;
4444
private SerializedProperty m_PrefabsList;
4545

46+
private SerializedProperty m_NetworkProfileMetrics;
47+
private SerializedProperty m_NetworkMessageMetrics;
48+
4649
private NetworkManager m_NetworkManager;
4750
private bool m_Initialized;
4851

@@ -109,6 +112,11 @@ private void Initialize()
109112
m_SpawnTimeOutProperty = m_NetworkConfigProperty.FindPropertyRelative("SpawnTimeout");
110113
m_LoadSceneTimeOutProperty = m_NetworkConfigProperty.FindPropertyRelative("LoadSceneTimeOut");
111114

115+
m_NetworkProfileMetrics = m_NetworkConfigProperty.FindPropertyRelative("NetworkProfileMetrics");
116+
#if MULTIPLAYER_TOOLS
117+
m_NetworkMessageMetrics = m_NetworkConfigProperty.FindPropertyRelative("NetworkMessageMetrics");
118+
#endif
119+
112120

113121
m_RpcHashSizeProperty = m_NetworkConfigProperty.FindPropertyRelative("RpcHashSize");
114122
m_PrefabsList = m_NetworkConfigProperty
@@ -143,6 +151,11 @@ private void CheckNullProperties()
143151
m_SpawnTimeOutProperty = m_NetworkConfigProperty.FindPropertyRelative("SpawnTimeout");
144152
m_LoadSceneTimeOutProperty = m_NetworkConfigProperty.FindPropertyRelative("LoadSceneTimeOut");
145153

154+
m_NetworkProfileMetrics = m_NetworkConfigProperty.FindPropertyRelative("NetworkProfilingMetrics");
155+
#if MULTIPLAYER_TOOLS
156+
m_NetworkMessageMetrics = m_NetworkConfigProperty.FindPropertyRelative("NetworkMessageMetrics");
157+
#endif
158+
146159
m_RpcHashSizeProperty = m_NetworkConfigProperty.FindPropertyRelative("RpcHashSize");
147160
m_PrefabsList = m_NetworkConfigProperty
148161
.FindPropertyRelative(nameof(NetworkConfig.Prefabs))
@@ -200,6 +213,11 @@ public override void OnInspectorGUI()
200213
}
201214
EditorGUILayout.PropertyField(m_RpcHashSizeProperty);
202215

216+
EditorGUILayout.PropertyField(m_NetworkProfileMetrics);
217+
#if MULTIPLAYER_TOOLS
218+
EditorGUILayout.PropertyField(m_NetworkMessageMetrics);
219+
#endif
220+
203221
EditorGUILayout.Space();
204222
EditorGUILayout.LabelField("Prefab Settings", EditorStyles.boldLabel);
205223
EditorGUILayout.PropertyField(m_ForceSamePrefabsProperty);
Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

com.unity.netcode.gameobjects/Components/NetworkDeltaPosition.cs renamed to com.unity.netcode.gameobjects/Runtime/Components/NetworkDeltaPosition.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ public struct NetworkDeltaPosition : INetworkSerializable
3232
/// </summary>
3333
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
3434
{
35-
HalfVector3.NetworkSerialize(serializer);
36-
if (SynchronizeBase)
35+
if (!SynchronizeBase)
3736
{
37+
HalfVector3.NetworkSerialize(serializer);
38+
}
39+
else
40+
{
41+
serializer.SerializeValue(ref DeltaPosition);
3842
serializer.SerializeValue(ref CurrentBasePosition);
3943
}
4044
}

com.unity.netcode.gameobjects/Components/NetworkRigidBodyBase.cs renamed to com.unity.netcode.gameobjects/Runtime/Components/NetworkRigidBodyBase.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -512,23 +512,6 @@ public override void OnNetworkDespawn()
512512
}
513513
SetInterpolation(m_OriginalInterpolation);
514514
}
515-
516-
/// <summary>
517-
/// When <see cref="UseRigidBodyForMotion"/> is enabled, the <see cref="NetworkTransform"/> will update Kinematic instances using
518-
/// the Rigidbody's move methods allowing Rigidbody interpolation settings to be taken into consideration by the physics simulation.
519-
/// </summary>
520-
/// <remarks>
521-
/// This will update the associated <see cref="NetworkTransform"/> during FixedUpdate which also avoids the added expense of adding
522-
/// a FixedUpdate to all <see cref="NetworkTransform"/> instances where some might not be using a Rigidbody.
523-
/// </remarks>
524-
private void FixedUpdate()
525-
{
526-
if (!IsSpawned || m_NetworkTransform == null || !UseRigidBodyForMotion)
527-
{
528-
return;
529-
}
530-
m_NetworkTransform.OnFixedUpdate();
531-
}
532515
}
533516
}
534517
#endif // COM_UNITY_MODULES_PHYSICS

0 commit comments

Comments
 (0)