Transport for Mirage using Epic online services relay
The preferred installation method is Unity Package manager.
If you are using unity 2019.3 or later:
- Open your project in unity
- Install Mirage
- Click on Windows -> Package Manager
- Add
com.playeveryware.eosas toscopedRegistries- Important: currently eos must be installed manually by adding
https://github.com/PlayEveryWare/eos_plugin_for_unity_upm.git#v1.0.4
- Important: currently eos must be installed manually by adding
- Add the
com.miragenet.epicsocketpackage`
This repo requires the following Scopes registers, These values can be set in project settings within the editor or by adding them to manifest.json
"scopedRegistries": [
{
"name": "OpenUPM",
"url": "https://package.openupm.com",
"scopes": [
"com.cysharp.unitask",
"com.openupm",
"com.miragenet",
"com.playeveryware.eos"
]
}Alternatively to OpenUPM you can install using git url by adding this to manifest.json
"com.miragenet.epicsocket": "https://github.com/MirageNet/EpicSocket.git?path=/Assets/EpicSocket#v1.0.0-beta.1"Check eos_plugin_for_unity for Epic setup and examples
When using EpicSocketFactory with Mirage you should start the client/server via the EpicSocketFactory instead of by themselves.
This is because the SocketFactory will make a connection to the relay first and then start the client/server when the relay is ready to use (this avoids timeout issues).
publicstaticasyncUniTaskHostWithEpic(NetworkManagermanager,EpicSocketFactoryepicFactory){awaitepicFactory.InitializeAsync();varlobbyHelper=newLobbyHelper(EOSManager.Instance.GetProductUserId(),EOSManager.Instance.GetEOSLobbyInterface());epicFactory.StartAsHost(manager.Server,manager.Client);awaitlobbyHelper.StartLobby(4,"Default");}publicstaticasyncUniTask<LobbyDetails>GetFirstLobby(EpicSocketFactoryepicFactory){awaitepicFactory.InitializeAsync();varlobbyHelper=newLobbyHelper(EOSManager.Instance.GetProductUserId(),EOSManager.Instance.GetEOSLobbyInterface());varlobbies=awaitlobbyHelper.GetAllLobbies();// most of the time you will want to have the user pick the lobby, but for this example we just pick the firstreturnlobbies.First();}publicstaticasyncUniTaskConnectToLobby(NetworkManagermanager,EpicSocketFactoryepicFactory,LobbyDetailslobby){varremoteUser=lobby.GetLobbyOwner(newLobbyDetailsGetLobbyOwnerOptions());awaitepicFactory.StartAsClient(manager.Client,remoteUser);}