Skip to content

Commit 2cca57e

Browse files
chore: EntityId update for UnityTransport and MP Tools (#3804)
* update Initial approach to resolve the circular dependency will be to use two unique defines created by both packages. NGO will use the assembly version define MP_TOOLS_2_2_8_OR_HIGHER. MP Tools will use the assembly version define NGO_2_8_0_OR_HIGHER. * style whitespace adjustments * update Simplifying this a bit as it is only used for testing purposes? * update Removing this version define as it is no longer needed. * style Removing comment
1 parent e21c0e4 commit 2cca57e

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -356,18 +356,9 @@ private struct PacketLossCache
356356
public float PacketLoss;
357357
};
358358

359-
/// <summary>
360-
/// TODO-FIXME:
361-
/// Multiplayer Tools subscribes to this event and does not have the EntityId udpate.
362-
/// </summary>
363-
#if FIXED
364359
#if UNITY_6000_2_OR_NEWER
365-
internal static event Action<EntityId, NetworkDriver> TransportInitialized;
366-
internal static event Action<EntityId> TransportDisposed;
367-
#else
368-
internal static event Action<int, NetworkDriver> TransportInitialized;
369-
internal static event Action<int> TransportDisposed;
370-
#endif
360+
internal static event Action<EntityId, NetworkDriver> OnDriverInitialized;
361+
internal static event Action<EntityId> OnDisposingDriver;
371362
#endif
372363
internal static event Action<int, NetworkDriver> TransportInitialized;
373364
internal static event Action<int> TransportDisposed;
@@ -449,13 +440,8 @@ private void InitDriver()
449440
out m_ReliableSequencedPipeline);
450441
#if UNITY_6000_2_OR_NEWER
451442
var entityId = GetEntityId();
452-
#if UNITY_6000_3_0A6_OR_HIGHER
453-
// TODO-FIXME: Since multiplayer tools subscribes to this and we have to validate against any package that
454-
// might use this action, we have to cast it down temporarily to avoid being blocked from getting these fixes in place.
455-
TransportInitialized?.Invoke((int)entityId.GetRawData(), m_Driver);
456-
#else
457-
TransportInitialized?.Invoke(entityId, m_Driver);
458-
#endif
443+
OnDriverInitialized?.Invoke(entityId, m_Driver);
444+
TransportInitialized?.Invoke(entityId.GetHashCode(), m_Driver);
459445
#else
460446
TransportInitialized?.Invoke(GetInstanceID(), m_Driver);
461447
#endif
@@ -477,14 +463,8 @@ private void DisposeInternals()
477463

478464
#if UNITY_6000_2_OR_NEWER
479465
var entityId = GetEntityId();
480-
#if UNITY_6000_3_0A6_OR_HIGHER
481-
// TODO-FIXME: Since multiplayer tools subscribes to this and we have to validate against any package that
482-
// might use this action, we have to cast it down temporarily to avoid being blocked from getting these fixes in place.
483-
TransportDisposed?.Invoke((int)entityId.GetRawData());
484-
#else
485-
TransportDisposed?.Invoke(entityId, m_Driver);
486-
#endif
487-
466+
OnDisposingDriver?.Invoke(entityId);
467+
TransportDisposed?.Invoke(entityId.GetHashCode());
488468
#else
489469
TransportDisposed?.Invoke(GetInstanceID());
490470
#endif

com.unity.netcode.gameobjects/Runtime/Unity.Netcode.Runtime.asmdef

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@
8484
"define": "SCENE_MANAGEMENT_SCENE_HANDLE_NO_INT_CONVERSION"
8585
},
8686
{
87-
"name": "Unity",
88-
"expression": "6000.5.0a1",
89-
"define": "SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG"
87+
"name": "Unity",
88+
"expression": "6000.5.0a1",
89+
"define": "SCENE_MANAGEMENT_SCENE_HANDLE_MUST_USE_ULONG"
9090
}
9191
],
9292
"noEngineReferences": false
93-
}
93+
}

0 commit comments

Comments
 (0)