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
36 changes: 18 additions & 18 deletions .yamato/wrench/validation-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ validate_-_netcode_gameobjects_-_6000_7_-_macos13arm:
retries: 1
- command: echo No internal packages to add.
- command: upm-pvp test --unity .Editor --packages "upm-ci~/packages/*.tgz" --results upm-ci~/pvp
timeout: 40
timeout: 90
retries: 0
- command: python PythonScripts/ignore_clean_console_failures.py
timeout: 5
Expand All @@ -39,10 +39,10 @@ validate_-_netcode_gameobjects_-_6000_7_-_macos13arm:
timeout: 10
retries: 0
- command: 'UnifiedTestRunner --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/editor --suite=editor "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
- command: 'UnifiedTestRunner --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/playmode --suite=playmode "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
after:
- command: bash .yamato/generated-scripts/infrastructure-instability-detection-mac.sh
Expand Down Expand Up @@ -104,7 +104,7 @@ validate_-_netcode_gameobjects_-_6000_7_-_ubuntu2204:
retries: 1
- command: echo No internal packages to add.
- command: upm-pvp test --unity .Editor --packages "upm-ci~/packages/*.tgz" --results upm-ci~/pvp
timeout: 40
timeout: 90
retries: 0
- command: python PythonScripts/ignore_clean_console_failures.py
timeout: 5
Expand All @@ -116,10 +116,10 @@ validate_-_netcode_gameobjects_-_6000_7_-_ubuntu2204:
timeout: 10
retries: 0
- command: 'UnifiedTestRunner --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/editor --suite=editor "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
- command: 'UnifiedTestRunner --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/playmode --suite=playmode "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
after:
- command: bash .yamato/generated-scripts/infrastructure-instability-detection-linux.sh
Expand Down Expand Up @@ -181,7 +181,7 @@ validate_-_netcode_gameobjects_-_6000_7_-_win10:
retries: 1
- command: echo No internal packages to add.
- command: upm-pvp test --unity .Editor --packages "upm-ci~/packages/*.tgz" --results upm-ci~/pvp
timeout: 40
timeout: 90
retries: 0
- command: python PythonScripts/ignore_clean_console_failures.py
timeout: 5
Expand All @@ -193,10 +193,10 @@ validate_-_netcode_gameobjects_-_6000_7_-_win10:
timeout: 10
retries: 0
- command: 'UnifiedTestRunner.exe --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/editor --suite=editor "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
- command: 'UnifiedTestRunner.exe --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/playmode --suite=playmode "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
after:
- command: .yamato\generated-scripts\infrastructure-instability-detection-win.cmd
Expand Down Expand Up @@ -259,7 +259,7 @@ validate_-_netcode_gameobjects_-_7000_0_-_macos13arm:
retries: 1
- command: echo No internal packages to add.
- command: upm-pvp test --unity .Editor --packages "upm-ci~/packages/*.tgz" --results upm-ci~/pvp
timeout: 40
timeout: 90
retries: 0
- command: python PythonScripts/ignore_clean_console_failures.py
timeout: 5
Expand All @@ -271,10 +271,10 @@ validate_-_netcode_gameobjects_-_7000_0_-_macos13arm:
timeout: 10
retries: 0
- command: 'UnifiedTestRunner --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/editor --suite=editor "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
- command: 'UnifiedTestRunner --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/playmode --suite=playmode "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
after:
- command: bash .yamato/generated-scripts/infrastructure-instability-detection-mac.sh
Expand Down Expand Up @@ -336,7 +336,7 @@ validate_-_netcode_gameobjects_-_7000_0_-_ubuntu2204:
retries: 1
- command: echo No internal packages to add.
- command: upm-pvp test --unity .Editor --packages "upm-ci~/packages/*.tgz" --results upm-ci~/pvp
timeout: 40
timeout: 90
retries: 0
- command: python PythonScripts/ignore_clean_console_failures.py
timeout: 5
Expand All @@ -348,10 +348,10 @@ validate_-_netcode_gameobjects_-_7000_0_-_ubuntu2204:
timeout: 10
retries: 0
- command: 'UnifiedTestRunner --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/editor --suite=editor "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
- command: 'UnifiedTestRunner --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/playmode --suite=playmode "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
after:
- command: bash .yamato/generated-scripts/infrastructure-instability-detection-linux.sh
Expand Down Expand Up @@ -413,7 +413,7 @@ validate_-_netcode_gameobjects_-_7000_0_-_win10:
retries: 1
- command: echo No internal packages to add.
- command: upm-pvp test --unity .Editor --packages "upm-ci~/packages/*.tgz" --results upm-ci~/pvp
timeout: 40
timeout: 90
retries: 0
- command: python PythonScripts/ignore_clean_console_failures.py
timeout: 5
Expand All @@ -425,10 +425,10 @@ validate_-_netcode_gameobjects_-_7000_0_-_win10:
timeout: 10
retries: 0
- command: 'UnifiedTestRunner.exe --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/editor --suite=editor "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
- command: 'UnifiedTestRunner.exe --testproject=testproject --editor-location=.Editor --clean-library --reruncount=1 --clean-library-on-rerun --artifacts-path=artifacts/playmode --suite=playmode "--ff={ops.upmpvpevidence.enable=true}" '
timeout: 40
timeout: 90
retries: 1
after:
- command: .yamato\generated-scripts\infrastructure-instability-detection-win.cmd
Expand Down
9 changes: 8 additions & 1 deletion .yamato/wrench/wrench_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@
"coverageCommands": [
"generateAdditionalMetrics;generateHtmlReport;assemblyFilters:ASSEMBLY_NAME;"
],
"dependantsToIgnoreInPreviewApv": {},
"dependantsToIgnoreInPreviewApv": {
"6000.7": [
"com.unity.services.multiplayer"
],
"7000.0": [
"com.unity.services.multiplayer"
]
},
"postPackCommands": []
}
},
Expand Down
12 changes: 11 additions & 1 deletion Tools/CI/Settings/NgoWrenchSettings.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using RecipeEngine.Api.Settings;
using RecipeEngine.Modules.Wrench.Helpers;
using RecipeEngine.Modules.Wrench.Models;
using RecipeEngine.Modules.Wrench.Platforms;
using RecipeEngine.Modules.Wrench.Settings;
using RecipeEngine.Unity.Abstractions.Editors;

namespace NGO.Cookbook.Settings;

Expand All @@ -13,7 +15,7 @@ public class NgoWrenchSettings : AnnotatedSettingsBase
static ValidationOptions validationOptions = new ValidationOptions()
{
ProjectPath = "testproject",
UtrTestingYamatoTimeout = 40
UtrTestingYamatoTimeout = 90
};

// update this to list all packages in this repo that you want to release.
Expand All @@ -34,6 +36,14 @@ public NgoWrenchSettings()
Wrench = new WrenchSettings(packagesRootPaths, PackageOptions);
Wrench.PvpProfilesToCheck = new HashSet<string>() { "supported" };
Wrench.Packages["com.unity.netcode.gameobjects"].PackAndPromotePlatformType = EditorPlatformType.Ubuntu2204;

// com.unity.services.multiplayer tests reference NGO test helpers that aren't exposed in the APV project, so they fail to compile there.
var apvDependantsToIgnore = new HashSet<string> { "com.unity.services.multiplayer" };
Wrench.Packages["com.unity.netcode.gameobjects"].DependantsToIgnoreInPreviewApv = new Dictionary<Editor, ISet<string>>
{
[new EditorVersion("6000.7")] = apvDependantsToIgnore,
[new EditorVersion("7000.0")] = apvDependantsToIgnore
};
}

public WrenchSettings Wrench { get; private set; }
Expand Down
14 changes: 1 addition & 13 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com).

## [Unreleased]

### Added
## [3.1.0] - 2026-10-04

### Changed

- Updated Netcode for Entities dependency to 7.1.0

### Deprecated

### Removed

### Fixed

### Security

### Obsolete

## [3.0.0] - 2026-09-14

### Added
Expand Down
37 changes: 32 additions & 5 deletions com.unity.netcode.gameobjects/Editor/InScenePlacedProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,47 @@
using UnityEngine;
using UnityEngine.SceneManagement;

#if UNITY_7000_0_OR_NEWER
using UnityEditor.Build.Content;
#endif

namespace Unity.Netcode.GameObjects.Editor
{
/// <summary>
/// A <see cref="IProcessSceneWithReport"/> that sets the <see cref
/// A build scene callback that sets the <see cref
/// "NetworkObject.InScenePlaced"/> property to true for all <see cref="NetworkObject"/>s in the scene.
/// Ensures that InScenePlaced is always true for all objects in the scene.
/// </summary>
/// <remarks>
/// This will always run as the game enters the scene,
/// This will always run as a scene is loaded in playmode or while processed for a player build.
/// </remarks>
#if UNITY_7000_0_OR_NEWER
internal class SetInScenePlaced : AssetPostprocessor
{
public override uint GetVersion() => 1;

public override int GetPostprocessOrder() => 0;

void OnProcessScene(Scene scene, SceneImportContext sceneImportContext)
{
InScenePlaceChecks.ReportSceneIssues(scene, sceneImportContext.awakeDidRun);
}
}
#else
internal class SetInScenePlaced : IProcessSceneWithReport
{
public int callbackOrder => 0;

public void OnProcessScene(Scene scene, BuildReport report)
{
InScenePlaceChecks.ReportSceneIssues(scene, Application.isPlaying);
}
}
#endif

internal static class InScenePlaceChecks
{
public static void ReportSceneIssues(Scene scene, bool hasAwakeRun)
{
var log = new ContextualLogger();
log.AddInfo(scene.name, scene.handle);
Expand All @@ -42,15 +69,15 @@ public void OnProcessScene(Scene scene, BuildReport report)
continue;
}

// If already marked, the do nothing.
// If already marked, do nothing.
if (networkObject.InScenePlaced)
{
continue;
}

networkObject.InScenePlaced = true;
// Will not be true when making a build and the values are serialized.
networkObject.InScenePlacedPostProcessorMarkedDuringRuntime = Application.isPlaying;
// Mark that awake has run so this could have been a dynamically instantiated object.
networkObject.InScenePlacedPostProcessorMarkedDuringRuntime = hasAwakeRun;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ public void WhenSendingNamedMessageToNullClientList_ArgumentNullExceptionIsThrow
[Test]
public unsafe void ErrorMessageIsPrintedWhenAttemptingToSendNamedMessageWithTooBigBuffer()
{
#if !DEBUG
Assert.Ignore("The message size check only exists in builds that define DEBUG.");
#endif
// First try a valid send with the maximum allowed size (this is atm 1264)
var msgSize = m_ServerNetworkManager.MessageManager.NonFragmentedMessageMaxSize - FastBufferWriter.GetWriteSize<NetworkMessageHeader>() - sizeof(ulong)/*MessageName hash*/ - sizeof(NetworkBatchHeader);
var bufferSize = m_ServerNetworkManager.MessageManager.NonFragmentedMessageMaxSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ public void WhenSendingNamedMessageToNullClientList_ArgumentNullExceptionIsThrow
[Test]
public unsafe void ErrorMessageIsPrintedWhenAttemptingToSendUnnamedMessageWithTooBigBuffer()
{
#if !DEBUG
Assert.Ignore("The message size check only exists in builds that define DEBUG.");
#endif
// First try a valid send with the maximum allowed size (this is atm 1272)
var msgSize = m_ServerNetworkManager.MessageManager.NonFragmentedMessageMaxSize - FastBufferWriter.GetWriteSize<NetworkMessageHeader>() - sizeof(NetworkBatchHeader);
var bufferSize = m_ServerNetworkManager.MessageManager.NonFragmentedMessageMaxSize;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Collections;
using System.Text;
using NUnit.Framework;
using Unity.Netcode.TestHelpers.Runtime;
using UnityEngine;
using UnityEngine.TestTools;

namespace Unity.Netcode.RuntimeTests
{
internal class ObjectNameIdentifierTests : NetcodeIntegrationTest
{
protected override int NumberOfClients => 1;

private GameObject m_Prefab;

protected override void OnServerAndClientsCreated()
{
m_Prefab = CreateNetworkObjectPrefab("TrackedObject");
base.OnServerAndClientsCreated();
}

private bool AllInstancesAreRegistered(StringBuilder errorLog, ulong networkObjectId)
{
foreach (var networkManager in m_NetworkManagers)
{
if (!s_GlobalNetworkObjects.TryGetValue(networkManager.LocalClientId, out var networkObjects) || !networkObjects.ContainsKey(networkObjectId))
{
errorLog.Append($"[Client-{networkManager.LocalClientId}] Object-{networkObjectId} is not registered.");
return false;
}
}
return true;
}

[UnityTest]
public IEnumerator OwnershipChangesKeepAllInstancesRegistered()
{
var authority = GetAuthorityNetworkManager();
var client = m_ClientNetworkManagers[0];
var authorityInstance = SpawnObject(m_Prefab, authority).GetComponent<NetworkObject>();
var networkObjectId = authorityInstance.NetworkObjectId;
yield return WaitForSpawnedOnAllOrTimeOut(authorityInstance);
AssertOnTimeout($"Timed out waiting for Object-{networkObjectId} to spawn on all instances!");

authorityInstance.ChangeOwnership(client.LocalClientId);
yield return WaitForConditionOrTimeOut(() => client.SpawnManager.SpawnedObjects[networkObjectId].OwnerClientId == client.LocalClientId);
AssertOnTimeout($"Timed out waiting for Client-{client.LocalClientId} to gain ownership of Object-{networkObjectId}!");
var errorLog = new StringBuilder();
Assert.IsTrue(AllInstancesAreRegistered(errorLog, networkObjectId), $"After gaining ownership: {errorLog}");

authorityInstance.RemoveOwnership();
yield return WaitForConditionOrTimeOut(() => client.SpawnManager.SpawnedObjects[networkObjectId].OwnerClientId == authority.LocalClientId);
AssertOnTimeout($"Timed out waiting for the authority to regain ownership of Object-{networkObjectId}!");
errorLog.Clear();
Assert.IsTrue(AllInstancesAreRegistered(errorLog, networkObjectId), $"After removing ownership: {errorLog}");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Unity.Netcode.TestHelpers.Runtime
/// </summary>
public class ObjectNameIdentifier : NetworkBehaviour
{
private ulong m_CurrentOwner;
private ulong m_RegisteredClientId;
private ulong m_CurrentNetworkObjectId;
private bool m_IsRegistered;

Expand Down Expand Up @@ -45,7 +45,7 @@ protected void RegisterAndLabelNetworkObject()
// This is required otherwise it will try to continue to update the NetworkBehaviour even if
// it has been destroyed.
m_NetworkObject = NetworkObject;
m_CurrentOwner = OwnerClientId;
m_RegisteredClientId = NetworkManager.LocalClientId;
m_CurrentNetworkObjectId = NetworkObjectId;

var serverOrClient = IsServer ? "Server" : "Client";
Expand Down Expand Up @@ -75,7 +75,7 @@ protected void DeRegisterNetworkObject()
{
if (m_IsRegistered)
{
NetcodeIntegrationTest.DeregisterNetworkObject(m_CurrentOwner, m_CurrentNetworkObjectId);
NetcodeIntegrationTest.DeregisterNetworkObject(m_RegisteredClientId, m_CurrentNetworkObjectId);
m_IsRegistered = false;
}
}
Expand Down
Loading