Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [2.0.0-pre.2] - 2023-05-02

### *General*
- Dropped support for Unity 2020.3; the next supported version is Unity 2021.3
- Fixed ``Failed to load type initialization for assembly Unity.Multiplayer.Tools.MetricTypes`` runtime exception when building using Managed Stripping level set to high.

### *Network Scene Visualization*

This release adds the Network Scene Visualization to the Multiplayer Tools Package. This tool allows users to visualize networking information (like bandwidth and ownership) on a per-object basis in the scene view using a number of visualizations, including mesh shading and a text overlay.

### *Runtime Net Stats Monitor*
- Fixed an issue that prevented using the ``RuntimeNetStatsMonitor.AddCustomValue`` API for stats that are only sampled per second.
- Switched to a new color-blind friendly color-palette for default variable colors in graphs, which will provide increased contrast and more default values. This new color palette is the same one used in the new Network Scene Visualization tool.
- Reduced the maximum sample count in Graphs and Simple Moving Average counters from 4096 to 512. Sample counts higher than 512 are no longer needed since per-second sampling was introduced in 1.1.0.
- Deprecated public methods that could be used to control the conditional compilation of the RNSM. Conditional compilation of the RNSM will be removed in a future major release.
  • Loading branch information
Unity Technologies committed May 2, 2023
1 parent ba56662 commit 9383add
Show file tree
Hide file tree
Showing 668 changed files with 8,506 additions and 8,373 deletions.
11 changes: 7 additions & 4 deletions Adapters/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Runtime.CompilerServices;

// Adapters
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.Adapters.MockNgo")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.Adapters.Ngo1")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.Adapters.Utp2")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.Adapters.Ngo1WithUtp2")]
Expand All @@ -10,12 +11,14 @@
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetworkSimulator.Editor")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetworkSimulator.Runtime")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetVis.Configuration")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetVis.Editor.UI")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetVis.Editor.Visualization")]

// Test assemblies
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetworkSimulator.Tests.Editor")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetStatsMonitor.Tests.Implementation")]

#if UNITY_INCLUDE_TESTS
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.Tests.Runtime.NetworkSimulator")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetworkSimulator.Tests.Editor")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation.Tests.Editor")]
[assembly: InternalsVisibleTo("Unity.Multiplayer.Tools.NetworkSimulator.Tests.Runtime")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
#endif
2 changes: 1 addition & 1 deletion Adapters/Components/Actions/IHandleNetworkParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class NetworkParameters

public int PacketLossPercent { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion Adapters/Components/Actions/ISimulateDisconnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ interface ISimulateDisconnect : IAdapterComponent
{
void SimulateDisconnect();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ namespace Unity.Multiplayer.Tools.Adapters
interface ISimulateDisconnectAndReconnect : IAdapterComponent, ISimulateDisconnect, ISimulateReconnect
{
}
}
}
2 changes: 1 addition & 1 deletion Adapters/Components/Actions/ISimulateReconnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ interface ISimulateReconnect : IAdapterComponent
{
void SimulateReconnect();
}
}
}
12 changes: 12 additions & 0 deletions Adapters/Components/Events/IGetConnectedClients.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;

namespace Unity.Multiplayer.Tools.Adapters
{
interface IGetConnectedClients : IAdapterComponent
{
IReadOnlyList<ClientId> ConnectedClients { get; }
event Action<ClientId> ClientConnectionEvent;
event Action<ClientId> ClientDisconnectionEvent;
}
}
3 changes: 3 additions & 0 deletions Adapters/Components/Events/IGetConnectedClients.cs.meta

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

1 change: 0 additions & 1 deletion Adapters/Components/Events/IMetricCollectionEvent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;

using Unity.Multiplayer.Tools.NetStats;

namespace Unity.Multiplayer.Tools.Adapters
Expand Down
36 changes: 33 additions & 3 deletions Adapters/Components/Queries/IGetBandwidth.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
using System;
using Unity.Multiplayer.Tools.Common;

namespace Unity.Multiplayer.Tools.Adapters
{
/// <summary>
/// Interface to get object bandwidth in bytes this frame
/// Interface to get the bandwidth in bytes of an object this frame
/// </summary>
interface IGetBandwidth : IAdapterComponent
{
int GetBandwidthBytes(ObjectId objectId);
/// <summary>
/// Returns the types of bandwidth that are supported by this adapter
/// </summary>
BandwidthTypes SupportedBandwidthTypes { get; }

/// <summary>
/// Returns the amount of bandwidth related to this object, filtered by bandwidth type and direction.
/// </summary>
/// <remarks>
/// If any of the bandwidth type flags are not supported by this adapter then they will be ignored
/// and will not contribute to the total bandwidth returned. If none of the bandwidth flags are
/// supported by this adapter then the bandwidth returned will be zero.
/// </remarks>
/// <exception cref="NoSubscribersException">
/// may be thrown if this method is called without any subscribers to <see cref="OnBandwidthUpdated"/>.
/// This is to ensure that object bandwidth is computed and stored only if required.
/// </exception>
float GetBandwidthBytes(
ObjectId objectId,
BandwidthTypes bandwidthTypes = BandwidthTypes.All,
NetworkDirection networkDirection = NetworkDirection.SentAndReceived);

/// <summary>
/// Event that is triggered when new object bandwidth data is available.
/// If there are no subscribers, then bandwidth may not be computed and stored
/// by the underlying implementation.
/// </summary>
event Action OnBandwidthUpdated;
}
}
}
2 changes: 1 addition & 1 deletion Adapters/Components/Queries/IGetGameObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ interface IGetGameObject : IAdapterComponent
{
GameObject GetGameObject(ObjectId objectId);
}
}
}
2 changes: 1 addition & 1 deletion Adapters/Components/Queries/IGetInterest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ interface IGetInterest : IAdapterComponent
{
bool GetInterest(ObjectId objectId);
}
}
}
4 changes: 2 additions & 2 deletions Adapters/Components/Queries/IGetObjectIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace Unity.Multiplayer.Tools.Adapters
/// </summary>
interface IGetObjectIds : IAdapterComponent
{
IEnumerable<ObjectId> ObjectIds { get; }
IReadOnlyList<ObjectId> ObjectIds { get; }
}
}
}
2 changes: 1 addition & 1 deletion Adapters/Components/Queries/IGetOwnership.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ interface IGetOwnership : IAdapterComponent
{
ClientId GetOwner(ObjectId objectId);
}
}
}
2 changes: 1 addition & 1 deletion Adapters/Components/Queries/IGetPriority.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ interface IGetPriority : IAdapterComponent
{
int GetPriority(ObjectId objectId);
}
}
}
15 changes: 14 additions & 1 deletion Adapters/Components/Queries/IGetRpcCount.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
using System;

namespace Unity.Multiplayer.Tools.Adapters
{
/// <summary>
/// Interface to get the number of RPCs called on an object this frame
/// </summary>
interface IGetRpcCount : IAdapterComponent
{
/// <exception cref="NoSubscribersException">
/// may be thrown if this method is called without any subscribers to <see cref="OnRpcCountUpdated"/>.
/// This is to ensure that object bandwidth is computed and stored only if required.
/// </exception>
int GetRpcCount(ObjectId objectId);

/// <summary>
/// Event that is triggered when new object RPC counts are available.
/// If there are no subscribers, then RPC counts may not be computed and stored
/// by the underlying implementation.
/// </summary>
event Action OnRpcCountUpdated;
}
}
}
2 changes: 1 addition & 1 deletion Adapters/Components/Queries/IGetTransformLastKnown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ interface IGetLastKnownObjectTransform : IAdapterComponent
{

}
}
}
2 changes: 1 addition & 1 deletion Adapters/Components/Queries/IGetTransformPredicted.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ interface IGetObjectTransformPredicted : IAdapterComponent
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ interface IGetTransformWithoutArtificialLatency : IAdapterComponent
{

}
}
}
2 changes: 1 addition & 1 deletion Adapters/Components/Queries/INetworkAvailability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ interface INetworkAvailability : IAdapterComponent
{
bool IsConnected { get; }
}
}
}
2 changes: 1 addition & 1 deletion Adapters/DataTypes/ObjectId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ enum ObjectId : long
{
// No members on purpose, this is a wrapper struct for strong typing
}
}
}
3 changes: 3 additions & 0 deletions Adapters/Exceptions.meta

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

18 changes: 18 additions & 0 deletions Adapters/Exceptions/NoSubscribersException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;

namespace Unity.Multiplayer.Tools.Adapters
{
/// <summary>
/// Exception for accessing information from the adapter
/// when there are no subscribers for this piece of information.
/// </summary>
class NoSubscribersException : Exception
{
public NoSubscribersException(string resourceName, string subscriptionMethodName)
: base(
$"Attempt to use {resourceName} without any subscribers. " +
$"Subscribe using {subscriptionMethodName}, so that the " +
$"adapter knows to compute and store this information.")
{}
}
}

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

2 changes: 1 addition & 1 deletion Adapters/IAdapterComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ interface IAdapterComponent
{

}
}
}
2 changes: 1 addition & 1 deletion Adapters/INetworkAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ interface INetworkAdapter
[CanBeNull]
T GetComponent<T>() where T : class, IAdapterComponent;
}
}
}
2 changes: 1 addition & 1 deletion Adapters/Metadata/AdapterMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ struct AdapterMetadata
{
public PackageInfo PackageInfo { get; set; }
};
}
}
2 changes: 1 addition & 1 deletion Adapters/Metadata/PackageInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ struct PackageInfo
public string PackageName { get; set; }
public PackageVersion Version { get; set; }
};
}
}
2 changes: 1 addition & 1 deletion Adapters/Metadata/PackageVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ struct PackageVersion
public int Patch { get; set; }
public string PreRelease { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion Common/Tests.meta → Adapters/MockNgo.meta

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

17 changes: 17 additions & 0 deletions Adapters/MockNgo/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Unity.Multiplayer.Tools.Adapters.MockNgo
{
class Constants
{
public const int k_DefaultSpawnMessageByteCount = 36;

public const int k_DefaultDespawnMessageByteCount = 8;

public const int k_DefaultOwnershipChangeByteCount = 16;

public const int k_DefaultPositionChangeByteCount = 12;

public const int k_DefaultRotationChangeByteCount = 12;

public const int k_DefaultScaleChangeByteCount = 12;
}
}
3 changes: 3 additions & 0 deletions Adapters/MockNgo/Constants.cs.meta

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

79 changes: 79 additions & 0 deletions Adapters/MockNgo/MockNetworkManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
using UnityEngine;

namespace Unity.Multiplayer.Tools.Adapters.MockNgo
{
/// <summary>
/// A mock network manager containing the mock client ID of the local instance
/// and parameters of the underlying mock network solution (like how many bytes
/// must be sent or received to update an object's position)
/// </summary>
/// <remarks>
/// There should be only one of these.
/// </remarks>
[AddComponentMenu("MP Tools Dev/" + nameof(MockNetworkManager), 1000)]
public class MockNetworkManager : MonoBehaviour
{
internal MockNgoAdapter Adapter { get; private set; }

void Awake()
{
Adapter = new(() => (ClientId)LocalClientID);
}

void LateUpdate()
{
Adapter.OnLateUpdate();
}

void OnDestroy()
{
Adapter.Dispose();
}

/// <summary>
/// The client ID of the local instance
/// </summary>
public int LocalClientID { get; set; } = 0;

/// <summary>
/// The number of bytes of network traffic incurred when an object is spawned.
/// </summary>
[field:Min(0)]
[field:SerializeField]
public int SpawnMessageByteCount { get; set; } = Constants.k_DefaultSpawnMessageByteCount;

/// <summary>
/// The number of bytes of network traffic incurred when an object is despawned.
/// </summary>
[field:Min(0)]
[field:SerializeField]
public int DespawnMessageByteCount { get; set; } = Constants.k_DefaultDespawnMessageByteCount;

/// <summary>
/// The number of bytes of network traffic incurred when an object's owner is changed
/// </summary>
[field:Min(0)]
[field:SerializeField]
public int OwnershipChangeByteCount { get; set; } = Constants.k_DefaultOwnershipChangeByteCount;

/// <summary>
/// The number of bytes of network traffic incurred when an object's position changes.
/// </summary>
[field:Min(0)]
[field:SerializeField]
public int PositionUpdateByteCount { get; set; } = Constants.k_DefaultPositionChangeByteCount;

/// <summary>
/// The number of bytes of network traffic incurred when an object's rotation changes.
/// </summary>
[field:Min(0)]
[field:SerializeField]
public int RotationUpdateByteCount { get; set; } = Constants.k_DefaultRotationChangeByteCount;

/// The number of bytes of network traffic incurred when an object's scale changes.
[field:Min(0)]
[field:SerializeField]
public int ScaleUpdateByteCount { get; set; } = Constants.k_DefaultScaleChangeByteCount;
}
}
Loading

0 comments on commit 9383add

Please sign in to comment.