com.unity.netcode.gameobjects@1.0.0-pre.4

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.4] - 2021-01-04

### Added

- Added `com.unity.modules.physics` and `com.unity.modules.physics2d` package dependencies (#1565)

### Removed

- Removed `com.unity.modules.ai` package dependency (#1565)
- Removed `FixedQueue`, `StreamExtensions`, `TypeExtensions` (#1398)

### Fixed
- Fixed in-scene NetworkObjects that are moved into the DDOL scene not getting restored to their original active state (enabled/disabled) after a full scene transition (#1354)
- Fixed invalid IL code being generated when using `this` instead of `this ref` for the FastBufferReader/FastBufferWriter parameter of an extension method. (#1393)
- Fixed an issue where if you are running as a server (not host) the LoadEventCompleted and UnloadEventCompleted events would fire early by the NetworkSceneManager (#1379)
- Fixed a runtime error when sending an array of an INetworkSerializable type that's implemented as a struct (#1402)
- NetworkConfig will no longer throw an OverflowException in GetConfig() when ForceSamePrefabs is enabled and the number of prefabs causes the config blob size to exceed 1300 bytes. (#1385)
- Fixed NetworkVariable not calling NetworkSerialize on INetworkSerializable types (#1383)
- Fixed NullReferenceException on ImportReferences call in NetworkBehaviourILPP (#1434)
- Fixed NetworkObjects not being despawned before they are destroyed during shutdown for client, host, and server instances. (#1390)
- Fixed KeyNotFound exception when removing ownership of a newly spawned NetworkObject that is already owned by the server. (#1500)
- Fixed NetworkManager.LocalClient not being set when starting as a host. (#1511)
- Fixed a few memory leak cases when shutting down NetworkManager during Incoming Message Queue processing. (#1323)

### Changed
- The SDK no longer limits message size to 64k. (The transport may still impose its own limits, but the SDK no longer does.) (#1384)
- Updated com.unity.collections to 1.1.0 (#1451)
This commit is contained in:
Unity Technologies
2021-01-04 00:00:00 +00:00
parent f5664b4cc1
commit 36d07fad5e
59 changed files with 1585 additions and 681 deletions

View File

@@ -0,0 +1,132 @@
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
namespace Unity.Netcode.RuntimeTests
{
/// <summary>
/// Tests that check OnNetworkDespawn being invoked
/// </summary>
public class NetworkObjectOnNetworkDespawnTests
{
private NetworkManager m_ServerHost;
private NetworkManager[] m_Clients;
private GameObject m_ObjectToSpawn;
private NetworkObject m_NetworkObject;
internal class OnNetworkDespawnTestComponent : NetworkBehaviour
{
public bool OnNetworkDespawnCalled { get; internal set; }
public override void OnNetworkSpawn()
{
OnNetworkDespawnCalled = false;
base.OnNetworkSpawn();
}
public override void OnNetworkDespawn()
{
OnNetworkDespawnCalled = true;
base.OnNetworkDespawn();
}
}
[UnitySetUp]
public IEnumerator Setup()
{
Assert.IsTrue(MultiInstanceHelpers.Create(1, out m_ServerHost, out m_Clients));
m_ObjectToSpawn = new GameObject();
m_NetworkObject = m_ObjectToSpawn.AddComponent<NetworkObject>();
m_ObjectToSpawn.AddComponent<OnNetworkDespawnTestComponent>();
// Make it a prefab
MultiInstanceHelpers.MakeNetworkObjectTestPrefab(m_NetworkObject);
var networkPrefab = new NetworkPrefab();
networkPrefab.Prefab = m_ObjectToSpawn;
m_ServerHost.NetworkConfig.NetworkPrefabs.Add(networkPrefab);
foreach (var client in m_Clients)
{
client.NetworkConfig.NetworkPrefabs.Add(networkPrefab);
}
yield return null;
}
[UnityTearDown]
public IEnumerator Teardown()
{
// Shutdown and clean up both of our NetworkManager instances
if (m_ObjectToSpawn)
{
Object.Destroy(m_ObjectToSpawn);
m_ObjectToSpawn = null;
}
MultiInstanceHelpers.Destroy();
yield return null;
}
public enum InstanceType
{
Server,
Host,
Client
}
/// <summary>
/// Tests that a spawned NetworkObject's associated NetworkBehaviours will have
/// their OnNetworkDespawn invoked during NetworkManager shutdown.
/// </summary>
[UnityTest]
public IEnumerator TestNetworkObjectDespawnOnShutdown([Values(InstanceType.Server, InstanceType.Host, InstanceType.Client)] InstanceType despawnCheck)
{
var useHost = despawnCheck == InstanceType.Server ? false : true;
var networkManager = despawnCheck == InstanceType.Host || despawnCheck == InstanceType.Server ? m_ServerHost : m_Clients[0];
// Start the instances
if (!MultiInstanceHelpers.Start(useHost, m_ServerHost, m_Clients))
{
Debug.LogError("Failed to start instances");
Assert.Fail("Failed to start instances");
}
// [Client-Side] Wait for a connection to the server
yield return MultiInstanceHelpers.WaitForClientsConnected(m_Clients, null, 512);
// [Host-Server-Side] Check to make sure all clients are connected
var clientCount = useHost ? m_Clients.Length + 1 : m_Clients.Length;
yield return MultiInstanceHelpers.WaitForClientsConnectedToServer(m_ServerHost, clientCount, null, 512);
// Spawn the test object
var spawnedObject = Object.Instantiate(m_NetworkObject);
var spawnedNetworkObject = spawnedObject.GetComponent<NetworkObject>();
spawnedNetworkObject.NetworkManagerOwner = m_ServerHost;
spawnedNetworkObject.Spawn(true);
// Get the spawned object relative to which NetworkManager instance we are testing.
var relativeSpawnedObject = new MultiInstanceHelpers.CoroutineResultWrapper<NetworkObject>();
yield return MultiInstanceHelpers.Run(MultiInstanceHelpers.GetNetworkObjectByRepresentation((x => x.GetComponent<OnNetworkDespawnTestComponent>() != null), networkManager, relativeSpawnedObject));
var onNetworkDespawnTestComponent = relativeSpawnedObject.Result.GetComponent<OnNetworkDespawnTestComponent>();
// Confirm it is not set before shutting down the NetworkManager
Assert.IsFalse(onNetworkDespawnTestComponent.OnNetworkDespawnCalled);
// Shutdown the NetworkManager instance we are testing.
networkManager.Shutdown();
// Since shutdown is now delayed until the post frame update
// just wait 2 frames before checking to see if OnNetworkDespawnCalled is true
var currentFrame = Time.frameCount + 2;
yield return new WaitUntil(() => Time.frameCount <= currentFrame);
// Confirm that OnNetworkDespawn is invoked after shutdown
Assert.IsTrue(onNetworkDespawnTestComponent.OnNetworkDespawnCalled);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 93f8ca7aa8b616746a1c15592830b047
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -115,6 +115,9 @@ namespace Unity.Netcode.RuntimeTests
Assert.That(clientNetworkManager.SpawnManager.SpawnedObjects.ContainsKey(dummyNetworkObjectId));
}
// Verifies that removing the ownership when the default (server) is already set does not cause
// a Key Not Found Exception
m_ServerNetworkManager.SpawnManager.RemoveOwnership(dummyNetworkObject);
var serverObject = m_ServerNetworkManager.SpawnManager.SpawnedObjects[dummyNetworkObjectId];
var clientObject = m_ClientNetworkManagers[0].SpawnManager.SpawnedObjects[dummyNetworkObjectId];