This repository has been archived on 2025-04-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
com.unity.netcode.gameobjects/Tests/Runtime/NestedNetworkManagerTests.cs
Unity Technologies 4818405514 com.unity.netcode.gameobjects@1.0.0-pre.5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

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

## [1.0.0-pre.5] - 2022-01-26

### Added

- Added `PreviousValue` in `NetworkListEvent`, when `Value` has changed (#1528)

### Changed

- NetworkManager's GameObject is no longer allowed to be nested under one or more GameObject(s).(#1484)
- NetworkManager DontDestroy property was removed and now NetworkManager always is migrated into the DontDestroyOnLoad scene. (#1484)

### Fixed

- Fixed network tick value sometimes being duplicated or skipped. (#1614)
- Fixed The ClientNetworkTransform sample script to allow for owner changes at runtime. (#1606)
2022-01-26 00:00:00 +00:00

38 lines
1.3 KiB
C#

using System.Collections;
using UnityEngine;
using UnityEngine.TestTools;
using Unity.Netcode;
using Unity.Netcode.RuntimeTests;
using Object = UnityEngine.Object;
namespace TestProject.RuntimeTests
{
public class NestedNetworkManagerTests
{
[UnityTest]
public IEnumerator CheckNestedNetworkManager()
{
var parent = new GameObject("ParentObject");
var networkManagerObject = new GameObject(nameof(CheckNestedNetworkManager));
// Make our NetworkManager's GameObject nested
networkManagerObject.transform.parent = parent.transform;
// Pre-generate the error message we are expecting to see
var messageToCheck = NetworkManager.GenerateNestedNetworkManagerMessage(networkManagerObject.transform);
var transport = networkManagerObject.AddComponent<SIPTransport>();
var networkManager = networkManagerObject.AddComponent<NetworkManager>();
networkManager.NetworkConfig = new NetworkConfig() { NetworkTransport = transport };
// Trap for the nested NetworkManager exception
LogAssert.Expect(LogType.Error, messageToCheck);
yield return new WaitForSeconds(0.02f);
// Clean up
Object.Destroy(parent);
yield return null;
}
}
}