13 KiB
Deprecations
Certain features of Unity Networking (UNet) were removed from Mirror or modified for various reasons. This page will identify all changed and removed features, properties, and methods, the reason for change or removal, and possible alternatives.
Note: Some changes in this document may apply to an upcoming release to the Asset Store.
Match Namespace & Host Migration
As part of the Unity Services, this entire namespace was removed. It didn't work well to begin with, and was incredibly complex to be part of the core networking package. We expect this, along with other back-end services, will be provided through standalone apps that have integration to Mirror.
Network Server Simple
This was too complex and impractical to maintain for what little it did, and was removed. There are much easier ways to make a basic listen server, with or without one of our transports.
Couch Co-Op
The core networking was greatly simplified by removing this low-hanging fruit. It was buggy, and too convoluted to be worth fixing. For those that need something like this, consider defining a non-visible player prefab as a message conduit that spawns actual player prefabs with client authority. All inputs would route through the conduit prefab to control the player objects.
Message Types
The MsgType
enumeration was removed. All message types are generated dynamically. Use Send<T>
instead.
Network Transform
Network Transform was significantly simplified so that it only syncs position, rotation and scale. Rigidbody support was removed. We may create a new NetworkRigidbody component that will be server authoritative with physics simulation and interpolation.
Network Animator
Network Animator was also simplified, as it batches all Animator parameters into a single update message.
SyncVar Hook Parameters
SyncVar property values are now updated before the hook is called, and hooks now require two parameters of the same type as the property: oldValue
and newValue
SyncListSTRUCT
Use SyncList<YourSpecialStruct>
instead.
SyncList Operations
OP_REMOVE
was replaced byOP_REMOVEAT
OP_DIRTY
was replaced byOP_SET
SyncIDictionary Operations
OP_DIRTY
was replaced byOP_SET
Quality of Service Flags
In classic UNet, QoS Flags were used to determine how packets got to the remote end. For example, if you needed a packet to be prioritized in the queue, you would specify a high priority flag which the Unity LLAPI would then receive and deal with appropriately. Unfortunately, this caused a lot of extra work for the transport layer and some of the QoS flags did not work as intended due to buggy code that relied on too much magic.
In Mirror, QoS flags were replaced with a "Channels" system. While the default transport, Telepathy, does not use channels at all because it's TCP-based, other transports, such as Ignorance and LiteNetLib4Mirror, do support them.
The currently defined channels are:
Channels.DefaultReliable = 0
Channels.DefaultUnreliable = 1
Changes by Class
NetworkManager
-
networkPort
Removed as part of separating Transports to components. Not all transports use ports, but those that do have a field for it. See Transports for more info. -
IsHeadless()
UseisHeadless
instead, as it's a property now. -
client
Use NetworkClient directly, it will be made static soon. For example, useNetworkClient.Send(message)
instead ofNetworkManager.client.Send(message)
. -
IsClientConnected()
Use static propertyNetworkClient.isConnected
instead. -
onlineScene
andofflineScene
These store full paths now, so use SceneManager.GetActiveScene().path instead. -
OnStartClient(NetworkClient client)
Override OnStartClient() instead since allNetworkClient
methods are static now. -
OnClientChangeScene(string newSceneName)
OverrideOnClientChangeScene(string newSceneName, SceneOperation sceneOperation, bool customHandling)
instead. -
OnClientChangeScene(string newSceneName, SceneOperation sceneOperation)
OverrideOnClientChangeScene(string newSceneName, SceneOperation sceneOperation, bool customHandling)
instead. -
OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)
OverrideOnServerAddPlayer(NetworkConnection conn)
instead. See Custom Player Spawn Guide for details. -
OnServerRemovePlayer(NetworkConnection conn, NetworkIdentity player)
UseNetworkServer.RemovePlayerForConnection(NetworkConnection conn, GameObject player, bool keepAuthority = false)
instead.
NetworkRoomManager
-
OnRoomServerCreateGamePlayer(NetworkConnection conn)
UseOnRoomServerCreateGamePlayer(NetworkConnection conn, GameObject roomPlayer)
instead. -
OnRoomServerSceneLoadedForPlayer(GameObject roomPlayer, GameObject gamePlayer)
UseOnRoomServerSceneLoadedForPlayer(NetworkConnection conn, GameObject roomPlayer, GameObject gamePlayer)
instead.
NetworkIdentity
-
clientAuthorityOwner
Use connectionToClient instead -
GetSceneIdenity
UseGetSceneIdentity
instead (typo in original name) -
RemoveClientAuthority(NetworkConnection conn)
NetworkConnection parameter is no longer needed and nothing is returned -
Local Player Authority checkbox
This checkbox is no longer needed, and we simplified how Authority works in Mirror.
NetworkBehaviour
-
sendInterval
attribute
UseNetworkBehaviour.syncInterval
field instead. Can be modified in the Inspector too. -
List<SyncObject> m_SyncObjects
UseList<SyncObject> syncObjects
instead. -
OnSetLocalVisibility(bool visible)
OverrideOnSetHostVisibility(bool visible)
instead. -
In Mirror 12,
OnRebuildObservers
,OnCheckObserver
, andOnSetHostVisibility
were moved to a separate class calledNetworkVisibility
-
In Mirror 12,
NetworkBehaviour.OnNetworkDestroy
was renamed toNetworkBehaviour.OnStopClient
.
NetworkConnection
-
hostId
Removed because it's not needed ever since we removed LLAPI as default. It's always 0 for regular connections and -1 for local connections. Useconnection.GetType() == typeof(NetworkConnection)
to check if it's a regular or local connection. -
isConnected
Removed because it's pointless. A NetworkConnection is always connected. -
InvokeHandlerNoData(int msgType)
UseInvokeHandler<T>
instead. -
playerController
renamed toidentity
since that's what it is: theNetworkIdentity
for the connection. If you need to convert a project after this change, Visual Studio / VS Code can help...read more here. -
RegisterHandler(short msgType, NetworkMessageDelegate handler)
UseNetworkServer.RegisterHandler<T>()
orNetworkClient.RegisterHandler<T>()
instead. -
UnregisterHandler(short msgType)
UseNetworkServer.UnregisterHandler<T>()
orNetworkClient.UnregisterHandler<T>()
instead. -
Send(int msgType, MessageBase msg, int channelId = Channels.DefaultReliable)
UseSend<T>(msg, channelId)
instead.
NetworkServer
-
FindLocalObject(uint netId)
UseNetworkIdentity.spawned[netId].gameObject
instead. -
RegisterHandler(int msgType, NetworkMessageDelegate handler)
UseRegisterHandler<T>(T msg)
instead. -
RegisterHandler(MsgType msgType, NetworkMessageDelegate handler)
UseRegisterHandler<T>(T msg)
instead. -
UnregisterHandler(int msgType)
UseUnregisterHandler<T>(T msg)
instead. -
UnregisterHandler(MsgType msgType)
UseUnregisterHandler<T>(T msg)
instead. -
SendToAll(int msgType, MessageBase msg, int channelId = Channels.DefaultReliable)
UseSendToAll<T>(T msg, int channelId = Channels.DefaultReliable)
instead. -
SendToClient(int connectionId, int msgType, MessageBase msg)
UseNetworkConnection.Send<T>(T msg, int channelId = Channels.DefaultReliable)
instead. -
SendToClient<T>(int connectionId, T msg)
UseNetworkConnection.Send<T>(T msg, int channelId = Channels.DefaultReliable)
instead. -
SendToClientOfPlayer(NetworkIdentity identity, int msgType, MessageBase msg)
UseSendToClientOfPlayer<T>(NetworkIdentity identity, T msg, int channelId = Channels.DefaultReliable)
instead. -
SendToReady(NetworkIdentity identity, short msgType, MessageBase msg, int channelId = Channels.DefaultReliable)
UseSendToReady<T>(NetworkIdentity identity, T msg, int channelId = Channels.DefaultReliable)
instead. -
SpawnWithClientAuthority(GameObject obj, GameObject player)
UseSpawn(GameObject, GameObject)
instead. -
SpawnWithClientAuthority(GameObject obj, NetworkConnection ownerConnection)
UseSpawn(obj, connection)
instead. -
SpawnWithClientAuthority(GameObject obj, Guid assetId, NetworkConnection ownerConnection)
UseSpawn(obj, assetId, connection)
instead
NetworkClient
-
NetworkClient singleton
UseNetworkClient
directly. Singleton isn't needed anymore as all functions are static now.
Example:NetworkClient.Send(message)
instead ofNetworkClient.singleton.Send(message)
. -
allClients
UseNetworkClient
directly instead. There is always exactly one client. -
GetRTT()
UseNetworkTime.rtt
instead. -
RegisterHandler(int msgType, NetworkMessageDelegate handler)
UseRegisterHandler<T>(T msg)
instead. -
RegisterHandler(MsgType msgType, NetworkMessageDelegate handler)
UseRegisterHandler<T>(T msg)
instead. -
UnregisterHandler(int msgType)
UseUnregisterHandler<T>(T msg)
instead. -
UnregisterHandler(MsgType msgType)
UseUnregisterHandler<T>(T msg)
instead. -
Send(short msgType, MessageBase msg)
UseSend<T>(T msg, int channelId = Channels.DefaultReliable)
with no message id instead -
ShutdownAll()
UseShutdown()
instead. There is only one client.
ClientScene
FindLocalObject(uint netId)
UseNetworkIdentity.spawned[netId]
instead.
Messages
Basic messages of simple types were all removed as unnecessary bloat. You can create your own message classes instead.
StringMessage
ByteMessage
BytesMessage
IntegerMessage
DoubleMessage
EmptyMessage
NetworkWriter
-
Write(bool value)
UseWriteBoolean
instead. -
Write(byte value)
UseWriteByte
instead. -
Write(sbyte value)
UseWriteSByte
instead. -
Write(short value)
UseWriteInt16
instead. -
Write(ushort value)
UseWriteUInt16
instead. -
Write(int value)
UseWriteInt32
instead. -
Write(uint value)
UseWriteUInt32
instead. -
Write(long value)
UseWriteInt64
instead. -
Write(ulong value)
UseWriteUInt64
instead. -
Write(float value)
UseWriteSingle
instead. -
Write(double value)
UseWriteDouble
instead. -
Write(decimal value)
UseWriteDecimal
instead. -
Write(string value)
UseWriteString
instead. -
Write(char value)
UseWriteChar
instead. -
Write(Vector2 value)
UseWriteVector2
instead. -
Write(Vector2Int value)
UseWriteVector2Int
instead. -
Write(Vector3 value)
UseWriteVector3
instead. -
Write(Vector3Int value)
UseWriteVector3Int
instead. -
Write(Vector4 value)
UseWriteVector4
instead. -
Write(Color value)
UseWriteColor
instead. -
Write(Color32 value)
UseWriteColor32
instead. -
Write(Guid value)
UseWriteGuid
instead. -
Write(Transform value)
UseWriteTransform
instead. -
Write(Quaternion value)
UseWriteQuaternion
instead. -
Write(Rect value)
UseWriteRect
instead. -
Write(Plane value)
UseWritePlane
instead. -
Write(Ray value)
UseWriteRay
instead. -
Write(Matrix4x4 value)
UseWriteMatrix4x4
instead. -
Write(NetworkIdentity value)
UseWriteNetworkIdentity
instead. -
Write(GameObject value)
UseWriteGameObject
instead. -
Write(byte[] buffer, int offset, int count)
UseWriteBytes
instead.
Transport
GetConnectionInfo(int connectionId, out string address)
UseServerGetClientAddress(int connectionId)
instead.
TelepathyTransport
MaxMessageSize
UseMaxMessageSizeFromClient
orMaxMessageSizeFromServer
instead.