Mirror/doc/General/Deprecations.md

332 lines
12 KiB
Markdown
Raw Normal View History

# Deprecations
2020-02-22 22:45:28 +00:00
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.
2019-01-09 01:44:48 +00:00
## Match Namespace
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.
2019-01-09 01:44:48 +00:00
2020-02-22 22:45:28 +00:00
## Network Server Simple
2020-02-22 22:45:28 +00:00
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.
2020-02-22 22:45:28 +00:00
## Couch Co-Op
2019-03-31 20:21:04 +00:00
2020-02-22 22:45:28 +00:00
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.
2020-02-22 22:45:28 +00:00
## Message Types
2019-11-06 04:43:07 +00:00
2020-02-22 22:45:28 +00:00
The `MsgType` enumeration was removed. All message types are generated dynamically. Use `Send<T>` instead.
2019-11-06 04:43:07 +00:00
2020-02-22 22:45:28 +00:00
## Network Transform
2020-02-22 22:45:28 +00:00
[Network Transform](../Components/NetworkTransform.md) 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.
2019-03-31 20:21:04 +00:00
2020-02-22 22:45:28 +00:00
## Network Animator
2019-01-09 01:44:48 +00:00
2020-02-22 22:45:28 +00:00
[Network Animator](../Components/NetworkAnimator.md) was also simplified, as it batches all Animator parameters into a single update message.
2019-01-09 01:44:48 +00:00
2020-02-22 22:45:28 +00:00
## SyncVar Hook Parameters
[SyncVar](../Guides/Sync/SyncVars.md)) 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
2019-01-09 01:44:48 +00:00
2020-02-22 22:45:28 +00:00
- `OP_REMOVE` was replaced by `OP_REMOVEAT`
- `OP_DIRTY` was replaced by `OP_SET`
## SyncIDictionary Operations
- `OP_DIRTY` was replaced by `OP_SET`
2019-01-09 01:44:48 +00:00
## Quality of Service Flags
2020-02-22 22:55:14 +00:00
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.
2019-01-09 01:44:48 +00:00
2020-02-22 22:55:14 +00:00
In Mirror, QoS flags were replaced with a "Channels" system. This system paves the way for future Mirror improvements, so you can send data on different channels - for example, you could have all game activity on channel 0, while in-game text chat is sent on channel 1 and voice chat is sent on channel 2. In the future, it may be possible to assign a transport system per channel, allowing one to have a TCP transport for critical game network data on channel 0, while in-game text and voice chat is running on a UDP transport in parallel on channel 1. Some transports, such as [Ignorance](../Transports/Ignorance.md), also provide legacy compatibility for those attached to QoS flags.
2019-01-09 01:44:48 +00:00
The currently defined channels are:
- `Channels.DefaultReliable = 0`
2019-01-09 01:44:48 +00:00
- `Channels.DefaultUnreliable = 1`
Currently, Mirror using it's default TCP transport will always send everything over a reliable channel. There is no way to bypass this behaviour without using a third-party transport, since TCP is always reliable. Other transports may support other channel sending methods.
2020-02-22 22:45:28 +00:00
## 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](../Transports/index.md) for more info.
- `IsHeadless()`
Use `isHeadless` instead, as it's a property now.
- `client`
Use NetworkClient directly, it will be made static soon. For example, use `NetworkClient.Send(message)` instead of `NetworkManager.client.Send(message)`.
- `IsClientConnected()`
Use static property `NetworkClient.isConnected` instead.
- `OnStartClient(NetworkClient client)`
Override OnStartClient() instead since all `NetworkClient` methods are static now.
- `OnClientChangeScene(string newSceneName)`
Override `OnClientChangeScene(string newSceneName, SceneOperation sceneOperation, bool customHandling)` instead.
- `OnClientChangeScene(string newSceneName, SceneOperation sceneOperation)`
Override `OnClientChangeScene(string newSceneName, SceneOperation sceneOperation, bool customHandling)` instead.
- `OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)`
Override `OnServerAddPlayer(NetworkConnection conn)` instead. See [Custom Player Spawn Guide](../Guides/GameObjects/SpawnPlayerCustom.md) for details.
### NetworkRoomManager
- `OnRoomServerCreateGamePlayer(NetworkConnection conn)`
Use `OnRoomServerCreateGamePlayer(NetworkConnection conn, GameObject roomPlayer)` instead.
### NetworkIdentity
- `clientAuthorityOwner`
Use connectionToClient instead
- `GetSceneIdenity`
2020-02-22 22:55:14 +00:00
Use `GetSceneIdentity` instead (typo in original name)
2020-02-22 22:45:28 +00:00
- `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](../Guides/Authority.md) works in Mirror.
### NetworkBehaviour
- `sendInterval` attribute
Use `NetworkBehaviour.syncInterval` field instead. Can be modified in the Inspector too.
- `List<SyncObject> m_SyncObjects`
Use `List<SyncObject> syncObjects` instead.
- `OnSetLocalVisibility(bool visible)`
Override `OnSetHostVisibility(bool visible)` instead.
### NetworkConnection
- `hostId`
2020-02-22 22:55:14 +00:00
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. Use `connection.GetType() == typeof(NetworkConnection)` to check if it's a regular or local connection.
2020-02-22 22:45:28 +00:00
- `isConnected`
2020-02-22 22:55:14 +00:00
Removed because it's pointless. A NetworkConnection is always connected.
2020-02-22 22:45:28 +00:00
- `InvokeHandlerNoData(int msgType)`
2020-02-22 22:55:14 +00:00
Use `InvokeHandler<T>` instead.
2020-02-22 22:45:28 +00:00
- `playerController`
renamed to `identity` since that's what it is: the `NetworkIdentity` for the connection. If you need to convert a project after this change, Visual Studio / VS Code can help...read more [here](PlayerControllerToIdentity.md).
- `RegisterHandler(short msgType, NetworkMessageDelegate handler)`
Use `NetworkServer.RegisterHandler<T>()` or `NetworkClient.RegisterHandler<T>()` instead.
- `UnregisterHandler(short msgType)`
Use `NetworkServer.UnregisterHandler<T>()` or `NetworkClient.UnregisterHandler<T>()` instead.
- `Send(int msgType, MessageBase msg, int channelId = Channels.DefaultReliable)`
Use `Send<T>(msg, channelId)` instead.
### NetworkServer
- `FindLocalObject(uint netId)`
Use `NetworkIdentity.spawned[netId]` instead.
- `RegisterHandler(int msgType, NetworkMessageDelegate handler)`
Use `RegisterHandler<T>(T msg)` instead.
- `RegisterHandler(MsgType msgType, NetworkMessageDelegate handler)`
Use `RegisterHandler<T>(T msg)` instead.
- `UnregisterHandler(int msgType)`
Use `UnregisterHandler<T>(T msg)` instead.
- `UnregisterHandler(MsgType msgType)`
Use `UnregisterHandler<T>(T msg)` instead.
- `SendToAll(int msgType, MessageBase msg, int channelId = Channels.DefaultReliable)`
Use `SendToAll<T>(T msg, int channelId = Channels.DefaultReliable)` instead.
- `SendToClient(int connectionId, int msgType, MessageBase msg)`
Use `NetworkConnection.Send<T>(T msg, int channelId = Channels.DefaultReliable)` instead.
- `SendToClient<T>(int connectionId, T msg)`
Use `NetworkConnection.Send<T>(T msg, int channelId = Channels.DefaultReliable)` instead.
- `SendToClientOfPlayer(NetworkIdentity identity, int msgType, MessageBase msg)`
Use `SendToClientOfPlayer<T>(NetworkIdentity identity, T msg, int channelId = Channels.DefaultReliable)` instead.
- `SendToReady(NetworkIdentity identity, short msgType, MessageBase msg, int channelId = Channels.DefaultReliable)`
Use `SendToReady<T>(NetworkIdentity identity, T msg, int channelId = Channels.DefaultReliable)` instead.
- `SpawnWithClientAuthority(GameObject obj, GameObject player)`
2020-02-22 22:55:14 +00:00
Use `Spawn(GameObject, GameObject)` instead.
2020-02-22 22:45:28 +00:00
- `SpawnWithClientAuthority(GameObject obj, NetworkConnection ownerConnection)`
Use `Spawn(obj, connection)` instead.
- `SpawnWithClientAuthority(GameObject obj, Guid assetId, NetworkConnection ownerConnection)`
Use `Spawn(obj, assetId, connection)` instead
### NetworkClient
- `NetworkClient singleton`
Use `NetworkClient` directly. Singleton isn't needed anymore as all functions are static now.
Example: `NetworkClient.Send(message)` instead of `NetworkClient.singleton.Send(message)`.
- `allClients`
Use `NetworkClient` directly instead. There is always exactly one client.
- `GetRTT()`
Use `NetworkTime.rtt` instead.
- `RegisterHandler(int msgType, NetworkMessageDelegate handler)`
Use `RegisterHandler<T>(T msg)` instead.
- `RegisterHandler(MsgType msgType, NetworkMessageDelegate handler)`
Use `RegisterHandler<T>(T msg)` instead.
- `UnregisterHandler(int msgType)`
Use `UnregisterHandler<T>(T msg)` instead.
- `UnregisterHandler(MsgType msgType)`
Use `UnregisterHandler<T>(T msg)` instead.
- `Send(short msgType, MessageBase msg)`
Use `Send<T>(T msg, int channelId = Channels.DefaultReliable)` with no message id instead
- `ShutdownAll()`
Use `Shutdown()` instead. There is only one client.
### ClientScene
- `FindLocalObject(uint netId)`
Use `NetworkIdentity.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)`
Use `WriteBoolean` instead.
- `Write(byte value)`
Use `WriteByte` instead.
- `Write(sbyte value)`
Use `WriteSByte` instead.
- `Write(short value)`
Use `WriteInt16` instead.
- `Write(ushort value)`
Use `WriteUInt16` instead.
- `Write(int value)`
Use `WriteInt32` instead.
- `Write(uint value)`
Use `WriteUInt32` instead.
- `Write(long value)`
Use `WriteInt64` instead.
- `Write(ulong value)`
Use `WriteUInt64` instead.
- `Write(float value)`
Use `WriteSingle` instead.
- `Write(double value)`
Use `WriteDouble` instead.
- `Write(decimal value)`
Use `WriteDecimal` instead.
- `Write(string value)`
Use `WriteString` instead.
- `Write(char value)`
Use `WriteChar` instead.
- `Write(Vector2 value)`
Use `WriteVector2` instead.
- `Write(Vector2Int value)`
Use `WriteVector2Int` instead.
- `Write(Vector3 value)`
Use `WriteVector3` instead.
- `Write(Vector3Int value)`
Use `WriteVector3Int` instead.
- `Write(Vector4 value)`
Use `WriteVector4` instead.
- `Write(Color value)`
Use `WriteColor` instead.
- `Write(Color32 value)`
Use `WriteColor32` instead.
- `Write(Guid value)`
Use `WriteGuid` instead.
- `Write(Transform value)`
Use `WriteTransform` instead.
- `Write(Quaternion value)`
Use `WriteQuaternion` instead.
- `Write(Rect value)`
Use `WriteRect` instead.
- `Write(Plane value)`
Use `WritePlane` instead.
- `Write(Ray value)`
Use `WriteRay` instead.
- `Write(Matrix4x4 value)`
Use `WriteMatrix4x4` instead.
- `Write(NetworkIdentity value)`
Use `WriteNetworkIdentity` instead.
- `Write(GameObject value)`
Use `WriteGameObject` instead.
- `Write(byte[] buffer, int offset, int count)`
Use `WriteBytes` instead.
### Transport
- `GetConnectionInfo(int connectionId, out string address)`
2020-02-22 22:55:14 +00:00
Use `ServerGetClientAddress(int connectionId)` instead.
2020-02-22 22:45:28 +00:00
### TelepathyTransport
- `MaxMessageSize`
2020-02-22 22:55:14 +00:00
Use `MaxMessageSizeFromClient` or `MaxMessageSizeFromServer` instead.