Skip to content

Commit ffd986f

Browse files
refactor - EntityId
Since MP Tools subscribes to the TransportInitialized and TransportDisposed methods and we have to vet against packages with dependencies, I am putting a temporary work-around to get past this issue so we can land the EntityId fix. Once MP Tools is updated for EntityId, we can re-enable the original fix.
1 parent f7dee36 commit ffd986f

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,22 @@ private struct PacketLossCache
355355
public int PacketsDropped;
356356
public float PacketLoss;
357357
};
358+
359+
/// <summary>
360+
/// TODO-FIXME:
361+
/// Multiplayer Tools subscribes to this event and does not have the EntityId udpate.
362+
/// </summary>
363+
#if FIXED
358364
#if UNITY_6000_2_OR_NEWER
359365
internal static event Action<EntityId, NetworkDriver> TransportInitialized;
360366
internal static event Action<EntityId> TransportDisposed;
361367
#else
362368
internal static event Action<int, NetworkDriver> TransportInitialized;
363369
internal static event Action<int> TransportDisposed;
364370
#endif
371+
#endif
372+
internal static event Action<int, NetworkDriver> TransportInitialized;
373+
internal static event Action<int> TransportDisposed;
365374

366375
/// <summary>
367376
/// Provides access to the <see cref="NetworkDriver"/> for this instance.
@@ -439,7 +448,14 @@ private void InitDriver()
439448
out m_UnreliableSequencedFragmentedPipeline,
440449
out m_ReliableSequencedPipeline);
441450
#if UNITY_6000_2_OR_NEWER
442-
TransportInitialized?.Invoke(GetEntityId(), m_Driver);
451+
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
443459
#else
444460
TransportInitialized?.Invoke(GetInstanceID(), m_Driver);
445461
#endif
@@ -460,7 +476,15 @@ private void DisposeInternals()
460476
m_SendQueue.Clear();
461477

462478
#if UNITY_6000_2_OR_NEWER
463-
TransportDisposed?.Invoke(GetEntityId());
479+
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+
464488
#else
465489
TransportDisposed?.Invoke(GetInstanceID());
466490
#endif

0 commit comments

Comments
 (0)