aws / amazon-gamelift-plugin-unity

The Amazon GameLift Plugin for Unity contains libraries and native UI that makes it easier to access GameLift resources and integrate GameLift into your Unity game. You can use the GameLift Unity Plugin to access GameLift APIs and deploy AWS CloudFormation templates for common gaming scenarios.
https://aws.amazon.com/gamelift/getting-started/
Apache License 2.0
76 stars 16 forks source link

Amazon GameLift Plugin for Unity Engine

GitHub license GitHub latest release version (by date) GitHub downloads all releases GitHub downloads latest release (by date)

Compatible with Unity 2021.3 LTS and 2022.3 LTS.

Overview

Amazon GameLift is a fully managed service that lets game developers to manage and scale dedicated game servers for session-based multiplayer games. The Amazon GameLift plugin for Unity provides tools that makes it quicker and easier to set up your Unity project for hosting on Amazon GameLift. Once the plugin is installed, you can access the plugin from within the Unity editor and start using it to integrate Amazon GameLift functionality into your client and server code. The plugin contains functionality to automatically bootstrap your game runtime environment to the AWS Cloud, fully test your game server integration with Amazon GameLift locally, and deploy your game servers on Amazon GameLift. For more information about using the plugin for Unity, see the Amazon GameLift plugin for Unity guide.

You can use built-in templates to deploy your game for the following common scenarios.

Each scenario uses an AWS CloudFormation template to deploy a resource stack for your game server solution. You can view and manage your resource stacks in the AWS Management Console for CloudFormation.

Prerequisites

Install the plugin

Complete the following steps to install and enable the plugin for your multiplayer game project. For more details, see the Amazon GameLift documentation.

  1. Install the Amazon GameLift Plugin for Unity.

    1. Find the com.amazonaws.gamelift-<version>.tgz file within the downloaded release zip or follow the contribution guide to build the tarball yourself.
    2. In your Unity project, open Window > Package Manager.
    3. Click + > Add package from tarball... and select the above tarball.
  2. Install the Amazon GameLift C# Server SDK for Unity plugin (aka. lightweight Unity plugin).

    1. Find and unzip the GameLift-CSharp-ServerSDK-UnityPlugin-<version>.zip file within the downloaded release zip or download it from Amazon GameLift's Getting Started.
    2. In your Unity project, open Edit > Project Settings > Package Manager.
    3. Under Scoped Registries, click on the + button and enter the values for the UnityNuGet scoped registry:
      Name: Unity NuGet
      Url: https://unitynuget-registry.azurewebsites.net
      Scope(s): org.nuget
    4. In your Unity project, open Window > Package Manager.
    5. Click + > Add package from tarball... and select the tarball within the unzipped folder, com.amazonaws.gameliftserver.sdk-<version>.tgz.
  3. (Optional) Import the sample project and configure the build settings.

    1. In your Unity project, select Amazon GameLift > Sample Game > Import Sample Game and import all assets.
    2. In your Unity project, select Amazon GameLift > Sample Game > Initialize Settings.

Contributing to this plugin

Prerequisites

Modifying the plugin code

  1. Clone the amazon-gamelift-plugin-unity repository from GitHub.
  2. Run Scripts~\windows\release.ps1 -Sdk <version> in PowerShell to build the plugin and dependent libraries (only needed once).
  3. In Unity Hub, create a new project.
  4. Open Unity Package Manager, import project from disk, and select the package.json located in the plugin's root folder.
  5. Setup code debugging in Unity: https://docs.unity3d.com/Manual/ManagedCodeDebugging.html, and change Unity project to Debug Mode.
  6. A .sln file should be created in the Unity project root, you can open that with Visual Studio.
  7. Make changes to the plugin code, and Unity should recompile after each change.
  8. Once changes are made, run the unit tests via Window > General > Test Runner.

Packaging the plugin

Run Scripts~\windows\release.ps1 -Sdk <version> to clean, build, export, and package the plugin with the server SDK in a single command.

Alternatively:

  1. Run Scripts~\windows\clean.ps1 to delete all dlls and temp files (If you want to build faster, you can comment out .clean-download-files execution).
  2. Run Scripts~\windows\build.ps1 to build dlls and sample game.
  3. Run Scripts~\windows\export.ps1 -Sdk <version> to export the plugin into a tarball (.tgz) and package it with the server SDK in the project root folder.

Testing the plugin

Follow instructions in Unity Docs to enable your project for testing:

  1. Open the Project manifest (located at <project>/Packages/manifest.json).
  2. Verify com.amazonaws.gamelift is present as a dependency.
  3. Add to the bottom of the file:
    "testables": [ "com.amazonaws.gamelift" ]

After enabling testing, the project tests can be run via Unity Test Runner.

FAQ

What Unity versions are supported?

The Amazon GameLift Plug-in for Unity is compatible only with officially supported versions of Unity 2021.3 LTS and 2022.3 LTS for Windows and Mac OS.

Where are the logs?

An additional error log file related to the Unity game project can be found in the following location: logs/amazon-gamelift-plugin-logs[YYYYMMDD].txt. Note that the log file is created once a day.

Amazon GameLift Resources