Class NetworkSimulator
Add this component to any game object to configure network simulation parameters.
Inherited Members
Namespace: Unity.Multiplayer.Tools.NetworkSimulator.Runtime
Syntax
[AddComponentMenu("Netcode/Network Simulator")]
public class NetworkSimulator : MonoBehaviour, INotifyPropertyChanged, INetworkEventsApi
Fields
AutoRunScenario
Allows to determine if network scenarios should start automatically or not.
Declaration
[SerializeField]
public bool AutoRunScenario
Field Value
Type | Description |
---|---|
Boolean |
Properties
ConnectionPreset
The Connection Preset used to define a set of connection parameters to simulate the network condition at runtime.
Declaration
public INetworkSimulatorPreset ConnectionPreset { get; set; }
Property Value
Type | Description |
---|---|
INetworkSimulatorPreset |
CurrentPreset
Returns the current connection preset used to simulate network conditions.
Declaration
public INetworkSimulatorPreset CurrentPreset { get; }
Property Value
Type | Description |
---|---|
INetworkSimulatorPreset |
Implements
IsAvailable
Returns whether the underlying network transport is available.
Declaration
public bool IsAvailable { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
IsConnected
Returns whether the underlying network transport is connected.
Declaration
public bool IsConnected { get; }
Property Value
Type | Description |
---|---|
Boolean |
Implements
Scenario
The Network Scenario used to modify network connection parameters at runtime. The new scenario will start automatically under specific circumstances: If autorun is enabled and the application is in playmode and the new scenario is valid (not None/null) and the previous scenario was a running valid one.
Declaration
public NetworkScenario Scenario { get; set; }
Property Value
Type | Description |
---|---|
NetworkScenario |
Methods
ChangeConnectionPreset(INetworkSimulatorPreset)
Changes the current connection preset used to simulate network condition parameters.
Declaration
public void ChangeConnectionPreset(INetworkSimulatorPreset preset)
Parameters
Type | Name | Description |
---|---|---|
INetworkSimulatorPreset | preset | The Network Simulator Preset being set. |
Implements
Disconnect()
Simulates a network disconnection.
Declaration
public void Disconnect()
Implements
Reconnect()
Reconnects after simulating a network disconnection.
Declaration
public void Reconnect()
Implements
TriggerLagSpike(TimeSpan)
Simulates a lag spike for the specified duration.
Declaration
public void TriggerLagSpike(TimeSpan duration)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | duration | The duration for which the lag spike shall last. |
Implements
TriggerLagSpikeAsync(TimeSpan)
Simulates a lag spike for the specified duration.
Declaration
public Task TriggerLagSpikeAsync(TimeSpan duration)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | duration | The duration for which the lag spike shall last. |
Returns
Type | Description |
---|---|
Task | The task that runs for the duration of the lag spike. |
Implements
Explicit Interface Implementations
INotifyPropertyChanged.PropertyChanged
Declaration
event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
Returns
Type | Description |
---|---|
PropertyChangedEventHandler |