This article is the above, next article: Mirror network library | Practical combat
1. Introduction
- Based on UNET, it has been tested in practice for 9 years since 2014;
- The server and client are one project;
- Use NetworkBehaviour instead of MonoBehaviour, as well as NetworkServer and NetworkClient;
- Mirror LTS coexists with Unity LTS and is supported for two years at a time. Only bugs are fixed and a consistent API is provided;
- Stable, modular and easy to use;
- Used in: Oculus Rift, Meta Quest, Steam, PC, Android, iOS, WebGL;
- Does not rely on any closed source dependencies other than Unity;
- Used under MIT license
2. Characteristics
Modular network protocol transport components
use KCP by default, but it is possible to use transport components from the community for low-level packet sending:
built in | Name | for |
---|---|---|
√ | KCP | reliable UDP |
√ | Telepathy | TCP |
√ | WebSockets | Websockets |
× | Ignorance | ENET UDP |
× | LiteNetLib | UDP |
× | FizzySteam | SteamNetwork |
× | FizzyFacepunch | SteamNetwork |
× | Epic Relay | Epic Online Services |
× | Bubble | Apple GameCenter |
× | Light Reflective Mirror | Self-Hosted Relay |
× | Oculus P2P | Oculus Platform Service |
3. Code
This is just a quick overview, please see the source code for specific implementation details. If there is any misunderstanding, please point it out.
PS:
- Based on v81.3.0 of the original warehouse
- There is no special explanation in the Editor part, just read the code by yourself
- Some actual cases of Examples will be explained in the next article.