Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .yamato/project-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ standards_{{ platform.name }}_{{ project.name }}_{{ editor }}:

- unity-downloader-cli --fast --wait -u {{ editor }} -c editor {% if platform.name == "mac" %} --arch arm64 {% endif %} # For macOS we use ARM64 models. Downloads basic editor
- .Editor/Unity -batchmode -nographics -logFile - -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -projectPath {{ project.path }} -quit # This command is used to invoke Unity in a "headless" mode. It's used to sync the project
- dotnet run --project=dotnet-tools/netcode.standards -- --project={{ project.path }} --check # Runs standards check
- dotnet run --project=dotnet-tools/netcode.standards -- --project={{ project.path }} --fix # Auto-fix formatting issues
- git checkout -- {{ project.path }}/Packages/manifest.json {{ project.path }}/Packages/packages-lock.json {{ project.path }}/ProjectSettings/ProjectVersion.txt 2>/dev/null || true # Restore files that Unity may have modified (we only want to check code formatting)
- 'git diff --exit-code || (echo "ERROR: Code formatting issues found. Run dotnet run --project=dotnet-tools/netcode.standards -- --project={{ project.path }} --fix locally and commit the changes." && exit 1)' # Fail if formatter made any changes
{% endfor -%}
{% endfor -%}
{% endfor -%}
6 changes: 3 additions & 3 deletions .yamato/project.metafile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
small_agent_platform:
- name: ubuntu
type: Unity::VM
image: package-ci/ubuntu-22.04:v4.77.0
image: package-ci/ubuntu-22.04:v4.81.0
flavor: b1.small


Expand All @@ -39,13 +39,13 @@ test_platforms:
default:
- name: ubuntu
type: Unity::VM
image: package-ci/ubuntu-22.04:v4.77.0
image: package-ci/ubuntu-22.04:v4.81.0
flavor: b1.large
standalone: StandaloneLinux64
desktop:
- name: ubuntu
type: Unity::VM
image: package-ci/ubuntu-22.04:v4.77.0
image: package-ci/ubuntu-22.04:v4.81.0
flavor: b1.large
smaller_flavor: b1.medium
larger_flavor: b1.xlarge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ private void DisplayNetworkRigidbodyProperties()
public override void OnInspectorGUI()
{
var networkRigidbodyBase = target as NetworkRigidbodyBase;
void SetExpanded(bool expanded) { networkRigidbodyBase.NetworkRigidbodyBaseExpanded = expanded; };
void SetExpanded(bool expanded)
{
networkRigidbodyBase.NetworkRigidbodyBaseExpanded = expanded;
}

DrawFoldOutGroup<NetworkRigidbodyBase>(networkRigidbodyBase.GetType(), DisplayNetworkRigidbodyProperties, networkRigidbodyBase.NetworkRigidbodyBaseExpanded, SetExpanded);
base.OnInspectorGUI();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ private void DrawToggleProperty(Rect rect, string label, SerializedProperty prop
public override void OnInspectorGUI()
{
var networkTransform = target as NetworkTransform;
void SetExpanded(bool expanded) { networkTransform.NetworkTransformExpanded = expanded; };
void SetExpanded(bool expanded)
{
networkTransform.NetworkTransformExpanded = expanded;
}

DrawFoldOutGroup<NetworkTransform>(networkTransform.GetType(), DisplayNetworkTransformProperties, networkTransform.NetworkTransformExpanded, SetExpanded);
base.OnInspectorGUI();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,8 @@ static AnimationParamEnumWrapper()
/// </summary>
private void SpawnCleanup()
{
if (m_NetworkAnimatorStateChangeHandler != null)
{
m_NetworkAnimatorStateChangeHandler.DeregisterUpdate();
m_NetworkAnimatorStateChangeHandler = null;
}
m_NetworkAnimatorStateChangeHandler?.DeregisterUpdate();
m_NetworkAnimatorStateChangeHandler = null;
}

public override void OnDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public interface IContactEventHandler
/// <summary>
/// Should return a <see cref="Rigidbody"/>.
/// </summary>
Rigidbody GetRigidbody();
public Rigidbody GetRigidbody();

/// <summary>
/// Invoked by the <see cref="RigidbodyContactEventManager"/> instance.
Expand All @@ -49,7 +49,7 @@ public interface IContactEventHandler
/// <param name="contactPoint">The world space location of the contact event.</param>
/// <param name="hasCollisionStay">Will be set if this is a collision stay contact event (i.e. it is not the first contact event and continually has contact)</param>
/// <param name="averagedCollisionStayNormal">The average normal of the collision stay contact over time.</param>
void ContactEvent(ulong eventId, Vector3 averagedCollisionNormal, Rigidbody collidingBody, Vector3 contactPoint, bool hasCollisionStay = false, Vector3 averagedCollisionStayNormal = default);
public void ContactEvent(ulong eventId, Vector3 averagedCollisionNormal, Rigidbody collidingBody, Vector3 contactPoint, bool hasCollisionStay = false, Vector3 averagedCollisionStayNormal = default);
}

/// <summary>
Expand All @@ -62,7 +62,7 @@ public interface IContactEventHandlerWithInfo : IContactEventHandler
/// Invoked by <see cref="RigidbodyContactEventManager"/> for each set of contact events it is processing (prior to processing).
/// </summary>
/// <returns><see cref="ContactEventHandlerInfo"/></returns>
ContactEventHandlerInfo GetContactEventHandlerInfo();
public ContactEventHandlerInfo GetContactEventHandlerInfo();
}

/// <summary>
Expand Down
12 changes: 4 additions & 8 deletions com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1623,12 +1623,8 @@ internal void ShutdownInternal()

// Shutdown connection manager last which shuts down transport
ConnectionManager.Shutdown();

if (MessageManager != null)
{
MessageManager.Dispose();
MessageManager = null;
}
MessageManager?.Dispose();
MessageManager = null;

// Let the NetworkSceneManager clean up its two SceneEvenData instances
SceneManager?.Dispose();
Expand Down Expand Up @@ -1745,9 +1741,9 @@ private void OnDestroy()
/// </summary>
internal interface INetworkManagerHelper
{
bool NotifyUserOfNestedNetworkManager(NetworkManager networkManager, bool ignoreNetworkManagerCache = false, bool editorTest = false);
public bool NotifyUserOfNestedNetworkManager(NetworkManager networkManager, bool ignoreNetworkManagerCache = false, bool editorTest = false);

void CheckAndNotifyUserNetworkObjectRemoved(NetworkManager networkManager, bool editorTest = false);
public void CheckAndNotifyUserNetworkObjectRemoved(NetworkManager networkManager, bool editorTest = false);

internal NetcodeAnalytics Analytics();
}
Expand Down
63 changes: 50 additions & 13 deletions com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,8 @@ public void DeferDespawn(int tickOffset, bool destroy = true)
/// In order for this status to be applied, the the <see cref="NetworkObject"/> must have the <see cref="OwnershipStatus.RequestRequired"/>
/// flag set and a non-owner client must have sent a request via <see cref="RequestOwnership"/>.
/// </summary>
public bool IsRequestInProgress => ((OwnershipStatusExtended)Ownership).HasFlag(OwnershipStatusExtended.Requested);
public bool IsRequestInProgress =>
((OwnershipStatusExtended)Ownership).HasFlag(OwnershipStatusExtended.Requested);

/// <summary>
/// Determines whether a NetworkObject can be distributed to other clients during
Expand Down Expand Up @@ -2917,18 +2918,54 @@ internal struct SerializedObject
internal ushort GetBitsetRepresentation()
{
ushort bitset = 0;
if (IsPlayerObject) { bitset |= k_IsPlayerObject; };
if (HasParent) { bitset |= k_HasParent; };
if (IsSceneObject) { bitset |= k_IsSceneObject; };
if (HasTransform) { bitset |= k_HasTransform; };
if (IsLatestParentSet) { bitset |= k_IsLatestParentSet; };
if (WorldPositionStays) { bitset |= k_WorldPositionStays; };
if (DestroyWithScene) { bitset |= k_DestroyWithScene; };
if (DontDestroyWithOwner) { bitset |= k_DontDestroyWithOwner; };
if (HasOwnershipFlags) { bitset |= k_HasOwnershipFlags; };
if (SyncObservers) { bitset |= k_SyncObservers; };
if (SpawnWithObservers) { bitset |= k_SpawnWithObservers; };
if (HasInstantiationData) { bitset |= k_HasInstantiationData; };
if (IsPlayerObject)
{
bitset |= k_IsPlayerObject;
}
if (HasParent)
{
bitset |= k_HasParent;
}
if (IsSceneObject)
{
bitset |= k_IsSceneObject;
}
if (HasTransform)
{
bitset |= k_HasTransform;
}
if (IsLatestParentSet)
{
bitset |= k_IsLatestParentSet;
}
if (WorldPositionStays)
{
bitset |= k_WorldPositionStays;
}
if (DestroyWithScene)
{
bitset |= k_DestroyWithScene;
}
if (DontDestroyWithOwner)
{
bitset |= k_DontDestroyWithOwner;
}
if (HasOwnershipFlags)
{
bitset |= k_HasOwnershipFlags;
}
if (SyncObservers)
{
bitset |= k_SyncObservers;
}
if (SpawnWithObservers)
{
bitset |= k_SpawnWithObservers;
}
if (HasInstantiationData)
{
bitset |= k_HasInstantiationData;
}
return bitset;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface INetworkUpdateSystem
/// The update method that is being executed in the context of related <see cref="NetworkUpdateStage"/>.
/// </summary>
/// <param name="updateStage">The <see cref="NetworkUpdateStage"/> that is being executed.</param>
void NetworkUpdate(NetworkUpdateStage updateStage);
public void NetworkUpdate(NetworkUpdateStage updateStage);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ internal enum TriggerType
/// There is a one second maximum lifetime of triggers to avoid memory leaks. After one second has passed
/// without the requested object ID being spawned, the triggers for it are automatically deleted.
/// </summary>
void DeferMessage(TriggerType trigger, ulong key, FastBufferReader reader, ref NetworkContext context, string messageType = null);
public void DeferMessage(TriggerType trigger, ulong key, FastBufferReader reader, ref NetworkContext context, string messageType = null);

/// <summary>
/// Cleans up any trigger that's existed for more than a second.
/// These triggers were probably for situations where a request was received after a despawn rather than before a spawn.
/// </summary>
void CleanupStaleTriggers();
public void CleanupStaleTriggers();

void ProcessTriggers(TriggerType trigger, ulong key);
public void ProcessTriggers(TriggerType trigger, ulong key);

/// <summary>
/// Cleans up any trigger that's existed for more than a second.
/// These triggers were probably for situations where a request was received after a despawn rather than before a spawn.
/// </summary>
void CleanupAllTriggers();
public void CleanupAllTriggers();
}
}
24 changes: 12 additions & 12 deletions com.unity.netcode.gameobjects/Runtime/Messaging/INetworkHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal interface INetworkHooks
/// <param name="clientId">The destination clientId</param>
/// <param name="message">The message being sent</param>
/// <param name="delivery"></param>
void OnBeforeSendMessage<T>(ulong clientId, ref T message, NetworkDelivery delivery) where T : INetworkMessage;
public void OnBeforeSendMessage<T>(ulong clientId, ref T message, NetworkDelivery delivery) where T : INetworkMessage;

/// <summary>
/// Called after an individual message is sent.
Expand All @@ -24,23 +24,23 @@ internal interface INetworkHooks
/// <param name="message">The message being sent</param>
/// <param name="delivery"></param>
/// <param name="messageSizeBytes">Number of bytes in the message, not including the message header</param>
void OnAfterSendMessage<T>(ulong clientId, ref T message, NetworkDelivery delivery, int messageSizeBytes) where T : INetworkMessage;
public void OnAfterSendMessage<T>(ulong clientId, ref T message, NetworkDelivery delivery, int messageSizeBytes) where T : INetworkMessage;

/// <summary>
/// Called before an individual message is received.
/// </summary>
/// <param name="senderId">The source clientId</param>
/// <param name="messageType">The type of the message being sent</param>
/// <param name="messageSizeBytes">Number of bytes in the message, not including the message header</param>
void OnBeforeReceiveMessage(ulong senderId, Type messageType, int messageSizeBytes);
public void OnBeforeReceiveMessage(ulong senderId, Type messageType, int messageSizeBytes);

/// <summary>
/// Called after an individual message is received.
/// </summary>
/// <param name="senderId">The source clientId</param>
/// <param name="messageType">The type of the message being sent</param>
/// <param name="messageSizeBytes">Number of bytes in the message, not including the message header</param>
void OnAfterReceiveMessage(ulong senderId, Type messageType, int messageSizeBytes);
public void OnAfterReceiveMessage(ulong senderId, Type messageType, int messageSizeBytes);

/// <summary>
/// Called before a batch of messages is sent
Expand All @@ -49,7 +49,7 @@ internal interface INetworkHooks
/// <param name="messageCount">Number of messages in the batch</param>
/// <param name="batchSizeInBytes">Number of bytes in the batch, including the batch header</param>
/// <param name="delivery"></param>
void OnBeforeSendBatch(ulong clientId, int messageCount, int batchSizeInBytes, NetworkDelivery delivery);
public void OnBeforeSendBatch(ulong clientId, int messageCount, int batchSizeInBytes, NetworkDelivery delivery);

/// <summary>
/// Called after a batch of messages is sent
Expand All @@ -58,23 +58,23 @@ internal interface INetworkHooks
/// <param name="messageCount">Number of messages in the batch</param>
/// <param name="batchSizeInBytes">Number of bytes in the batch, including the batch header</param>
/// <param name="delivery"></param>
void OnAfterSendBatch(ulong clientId, int messageCount, int batchSizeInBytes, NetworkDelivery delivery);
public void OnAfterSendBatch(ulong clientId, int messageCount, int batchSizeInBytes, NetworkDelivery delivery);

/// <summary>
/// Called before a batch of messages is received
/// </summary>
/// <param name="senderId">The source clientId</param>
/// <param name="messageCount">Number of messages in the batch</param>
/// <param name="batchSizeInBytes">Number of bytes in the batch, including the batch header</param>
void OnBeforeReceiveBatch(ulong senderId, int messageCount, int batchSizeInBytes);
public void OnBeforeReceiveBatch(ulong senderId, int messageCount, int batchSizeInBytes);

/// <summary>
/// Called after a batch of messages is received
/// </summary>
/// <param name="senderId">The source clientId</param>
/// <param name="messageCount">Number of messages in the batch</param>
/// <param name="batchSizeInBytes">Number of bytes in the batch, including the batch header</param>
void OnAfterReceiveBatch(ulong senderId, int messageCount, int batchSizeInBytes);
public void OnAfterReceiveBatch(ulong senderId, int messageCount, int batchSizeInBytes);


/// <summary>
Expand All @@ -84,7 +84,7 @@ internal interface INetworkHooks
/// <param name="messageType">The type of the message</param>
/// <param name="delivery"></param>
/// <returns></returns>
bool OnVerifyCanSend(ulong destinationId, Type messageType, NetworkDelivery delivery);
public bool OnVerifyCanSend(ulong destinationId, Type messageType, NetworkDelivery delivery);

/// <summary>
/// Called before a message is received. If this returns false, the message will be discarded.
Expand All @@ -94,7 +94,7 @@ internal interface INetworkHooks
/// <param name="messageContent">The FastBufferReader containing the message</param>
/// <param name="context">The NetworkContext the message is being processed in</param>
/// <returns></returns>
bool OnVerifyCanReceive(ulong senderId, Type messageType, FastBufferReader messageContent, ref NetworkContext context);
public bool OnVerifyCanReceive(ulong senderId, Type messageType, FastBufferReader messageContent, ref NetworkContext context);

/// <summary>
/// Called after a message is serialized, but before it's handled.
Expand All @@ -103,7 +103,7 @@ internal interface INetworkHooks
/// <param name="message">The message object</param>
/// <param name="context">The network context the message is being ahandled in</param>
/// <typeparam name="T"></typeparam>
void OnBeforeHandleMessage<T>(ref T message, ref NetworkContext context) where T : INetworkMessage;
public void OnBeforeHandleMessage<T>(ref T message, ref NetworkContext context) where T : INetworkMessage;

/// <summary>
/// Called after a message is serialized and handled.
Expand All @@ -112,6 +112,6 @@ internal interface INetworkHooks
/// <param name="message">The message object</param>
/// <param name="context">The network context the message is being ahandled in</param>
/// <typeparam name="T"></typeparam>
void OnAfterHandleMessage<T>(ref T message, ref NetworkContext context) where T : INetworkMessage;
public void OnAfterHandleMessage<T>(ref T message, ref NetworkContext context) where T : INetworkMessage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ namespace Unity.Netcode
/// </summary>
internal interface INetworkMessage
{
void Serialize(FastBufferWriter writer, int targetVersion);
bool Deserialize(FastBufferReader reader, ref NetworkContext context, int receivedMessageVersion);
void Handle(ref NetworkContext context);
int Version { get; }
public void Serialize(FastBufferWriter writer, int targetVersion);
public bool Deserialize(FastBufferReader reader, ref NetworkContext context, int receivedMessageVersion);
public void Handle(ref NetworkContext context);
public int Version { get; }
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ namespace Unity.Netcode
{
internal interface INetworkMessageProvider
{
List<NetworkMessageManager.MessageWithHandler> GetMessages();
public List<NetworkMessageManager.MessageWithHandler> GetMessages();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace Unity.Netcode
{
internal interface INetworkMessageSender
{
void Send(ulong clientId, NetworkDelivery delivery, FastBufferWriter batchData);
public void Send(ulong clientId, NetworkDelivery delivery, FastBufferWriter batchData);
}
}
Loading