Mirage is a high-level networking library for Unity. It's modular, performant, and designed to be easy to use, whether you're building an MMO, a co-op game, or an FPS.
Mirage is battle-tested in released games and built with security in mind, with many tools to help prevent multiplayer exploits.
Mirage is open source. Bug reports and feedback are welcome, either open an issue on Github or join the Discord.
// Server/Client events — listen from anywhere, no central manager needed
public class GameSetup : MonoBehaviour
{
public NetworkServer Server;
public NetworkClient Client;
private void Awake()
{
Server.Authenticated.AddListener(OnPlayerJoined);
Server.Disconnected.AddListener(OnPlayerLeft);
Client.Authenticated.AddListener(OnConnected);
}
private void OnPlayerJoined(INetworkPlayer player) { /* spawn logic */ }
private void OnPlayerLeft(INetworkPlayer player) { /* cleanup logic */ }
private void OnConnected(INetworkPlayer player) { /* client ready */ }
}
// NetworkBehaviour — SyncVars, RPCs, and Identity events
public class PlayerCombat : NetworkBehaviour
{
[SyncVar]
public int health = 100;
private void Awake()
{
Identity.OnStartServer.AddListener(OnStartServer);
}
private void OnStartServer() { /* server-side init */ }
[ServerRpc]
// Rate limit to block spam
[RateLimit(Refill = 1, MaxTokens = 5, Penalty = 10)]
public void CmdAttack(NetworkIdentity target)
{
// validate and apply damage
}
[ServerRpc]
[RateLimit(Refill = 1, MaxTokens = 5, Penalty = 50)]
// return values so client can await result to know if they were successful or not
public UniTask<bool> CmdBuyItem(int itemId)
{
if (!HasEnoughGold(itemId))
return UniTask.FromResult(false);
AddItemToInventory(itemId);
return UniTask.FromResult(true);
}
}To install Mirage, follow these steps:
- Mirage requires at least Unity 2022 LTS. You may install Unity 2022 LTS via the Unity website or via the Unity Hub.
You may use newer versions, however, LTS versions are strongly recommended as newer versions can contain bugs, glitches, or just flat-out break game projects. - Start a new project or open your existing one. If opening an existing one, it is strongly recommended to back it up before installing Mirage.
- Add the OpenUPM registry. Click on the
Editmenu, then selectProject settings..., selectPackage Manager, and add a scoped registry like so:
Name:OpenUPM
Url:https://package.openupm.com
Scopes: - Close the project settings.
- Open the package manager by clicking on the
Windowmenu and selectingPackage Manager. Then selectPackages,My Registries, select the latest version of Mirage and click install, like so:
- You may come back to the package manager at any time to uninstall Mirage or upgrade it.
If you prefer to install a specific version or hash directly from GitHub, you can add the following line to your Packages/manifest.json file under the dependencies section:
"com.miragenet.mirage": "https://github.com/MirageNet/Mirage.git?path=/Assets/Mirage#v156.2.4",If you've got a project already using Mirror and you want to migrate it to Mirage, it's recommended to check out our Migration Guide for a smooth transition. Also check the heading below, as there are some major differences between Mirage and the other network library.
Mirage is a hard fork of Mirror, with many added features, performance improvements, and security improvements.
| Mirage | Mirror |
|---|---|
| Installs via Package Manager (OpenUPM or GitHub URL) | Installs from the Unity Asset Store |
| Errors are thrown as exceptions | Errors are logged |
[ServerRpc] |
[Command] |
[ClientRpc(target = RpcTarget.Owner)] |
[TargetRpc] |
| Events: listen from any script, no central manager | Override methods: large NetworkManager class with single overrides |
| Follows C# code style and conventions | No consistency |
NetworkTime available in NetworkBehaviour |
NetworkTime is global static |
| Send any data as messages | Messages must implement NetworkMessage |
| Structured SocketLayer with consistent connection flow for all transports | Each transport implements its own connection logic |
Some notable features that Mirage has:
- Well-structured codebase — clear boundaries between systems make it easy to navigate and understand
- No static state — multiple server/client instances can run in the same Unity process
- Strict error handling — invalid calls throw exceptions so bugs surface immediately instead of silently corrupting state
- Network Behaviours can be on root or child GameObject
- Server RPCs can Return Values
- Bit Packing to easily optimize network messages and reduce bandwidth
- Rate Limiting and Max Length validation via attributes
- Error Flags to track misbehaving clients and what errors they are causing
- Version Defines
- Fast Play Mode support
Mirage is built upon fundamental pillars:
- Clean, readable codebase that follows C# conventions
- No singletons or global static state
- High test coverage
If you want to contribute to Mirage, follow these steps:
- Ensure git is installed. On Linux, install via your package manager. On macOS, it's included with the Xcode command-line tools.
- Clone the Mirage repository:
git clone https://github.com/MirageNet/Mirage.git
- Open the cloned repo in Unity 2022.3 LTS or later.
- Install git or use your preferred git client.
- As an administrator, clone with symbolic links support:
If you don't want to use administrator, add symlink support to your account. If you don't enable symlinks, you will be able to work on Mirage but Unity will not see the examples.
git clone -c core.symlinks=true https://github.com/MirageNet/Mirage.git
- Open in Unity 2022.3 LTS or later and have fun!
Mirage supports multiple ways of transporting data:
- Native UDP socket (default on Windows and Linux) with fallback to C# UDP Sockets (default on macOS and other platforms)
- Steam (via MirageSteamworks)
- Epic Online Services (via EpicSocket)
- WebSocket for WebGL clients (via SimpleWebSocket)
- MirageStandalone — Run Mirage servers without Unity
- Mirage.Core — Core serialization and networking, framework-independent
- Mirage.Godot — Mirage networking for Godot
- See the Development Environment Setup above.
- Fork this Mirage repository.
- Using your new fork, create your feature branch:
git checkout -b my-new-feature - Then commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request and let the team review your work. 😃
The team will review it ASAP and give it the stamp of approval, ask for changes or decline it with a detailed explanation.
Thank you for using Mirage and we hope to see your project be successful!
