
Edgegap Plugin - Automated Game Server Hosting - Unity Tutorial
Hi,
In this video, we will cover how to easily set up any Unity project to deploy, and host, dedicated game server directly from Unity’s editor using the Edgegap plugin.
As to get your game online and playable, worldwide, in seconds.
Let’s get to it.
Chapter 1: Setup
Before using the plugin, there are three requirements to ensure Unity works for dedicated servers.
First, make sure you use the latest Edgegap plugin.
While Edgegap is available in the Unity asset store, a far easier way to add and keep Edgegap up to date directly from Unity’s editor through the “Git” method.
From the Unity editor, select "Window", then "Package Manager". Click on the "+" button and select "Add Package from git URL". Then, type the GIT URL, such as ‘”github dot com slash edgegap slash Edgegap dash unity dash plugin dot git”.
Finally, click "Add", and the package will automatically download and be added to your project!
Second, head over to Unity’s Hub to confirm you have installed all three “Linux Dedicated Server Build Support” module in your project. If not, simply click on the package and install it.
The third and final prerequisite is to install and run Docker. It containerizes your game servers to help it deploy and run faster. If you haven’t yet, you can go watch our Docker installation video, or head over to Docker dot com and follow the installation procedure. It’s easy and takes just a few minutes.
Now, let’s get started!
Chapter 2: Edgegap’s Unity Plugin
Load up your project. In our case, we are using the tank sample project from Mirror Networking that is already setup for dedicated game servers. Any project set up for dedicated server will work with Edgegap’s plugin.
From the top navigation menu, select “Tool” and then click on “Edgegap Hosting” which opens the plugin’s window.
To function, you first have to generate a token.
To do so, you must create an Edgegap account. Click on the “Sign in to Edgegap” button which will open up your browser.
If you do not have an account, signing up is free and takes just a few seconds. Select “Get Started” at the bottom, then input your email and a password and opt in to our terms. You’ll then instantly get a verification email. Click on “Confirm Your Email” to validate your account. Finally, input your organization’s name and confirm.
This is Edgegap application’s dashboard. We strongly recommend exploring it with the tour, but we’ll skip it for this video. Automatically, a pop up with your unique OneClick Token appears. Simply copy it by clicking on the clipboard icon and paste it directly in the plugin’s text box.
Then, select “Validate Token”. If the token is valid, the “Build Your Server” tab opens automatically.
If needed, change your Build Folder Name.
Then, select “build your server”.
Once the server build process is successful, move to the third step – containerizing your game server.
Build path is the relative path to your server build artifact, let’s keep the default for now.
Image name is a unique identifier of your choice, labeling your server build before shipping. Let’s keep the default for now too.
Image tag is an identifier pointing to a specific version of your image’s Timestamps, which is a great option for tagging which you should use in production. As this is an initial test, we will keep it here as default to keep things simple.
Path to Dockerfile can be used to customize the recipe for your images, but keep it to the default for now.
Optional docker build parameters can be used to further instruct Docker on finer nuances.
And let’s go. Select “Containerize with Docker".
After a few minutes, your containerization should be successful.
Let’s deploy locally, namely on your machine, to make sure the server image is functioning properly before we upload and deploy. Make sure to read our documentation to learn more about these options, including port configurations.
We’ll skip it for this video.
Take note of the port number, namely here it is seven, seven, seven, seven, and the protocol type – in this case UDP, for later.
Now, it is time to get your server online to our platform’s container registry and make your game playable worldwide.
Application name, server image name and tag provide more customization options, but we’ll keep them to default here again.
Click on “Upload image and create app version” and after a few seconds, a browser to the platform opens up. You can once again configure optional settings, including vCPU resource usage, memory and more, but we’ll create a new version with defaults settings.
You will now be prompted to define a Port for your new Application version. Make sure to set the same server port value from the “Test Your Server Locally” step. Click “submit”.
While you can deploy the server from the web platform, return to the plugin to deploy it from Unity.
Under the “Deploy a Server to Edgegap” section, while application name is filled automatically, select the version from the platform you want to deploy. Click on “Deploy to Cloud”, and after a few seconds of waiting, your game server is now available for the world to play.
Congratulations!
Chapter 3: Testing
Evidently, test things in your projects too.
Mirror sample has its own simple test, and each project is likely unique. In our case, select the deployment from the platform, and copy the host’s URL and note the external port. Then, in the engine, close the plugin’s window and start the project. Once running, replace the client’s address with the host’s URL and change to the external port from the deployment. Finally, launch the server, and it connects to the deploy easily.
Once you are done testing, return to the Edgegap plugin to automatically stop the server instance by selecting “Stop Server”.
That is all for the Edgegap plugin for Unity, which empower game developers with automated game server and simple hosting.
The likely next step in your game development will be to connect players. For more information on Edgegap’s free, simple and fully automated matchmaker, you can check out our tutorial.
Thanks for watching!
