Prerequisites

Why Unity 2019.4?

Unity requires at least 2019.4 to use the WebRTC plugin.

Best Practices for Online Distribution

For all projects built in Unity, follow this checklist to ensure your project is optimized for render streaming distribution at scale.

  1. Check Input System
  2. Reduce package size
  3. Optimize performance
  4. Check run state
  5. Test loading time

Check Input System

Ensure that your project is implemented and utilizing the new Unity Input system. If your project does not use the new input system please follow the Installation Guide by Unity to update it.

Reduce Package Size

Before preparing your project for cloud deployment it’s important to optimize your game and reduce the file size if possible. AWS instances used within the PureWeb Reality platform have limitations on the maximum file size.

Keep the file size below 50GB, ideally 5GB or less.

Smaller project files result in shorter load and startup times (the time it takes for the stream to start once a user has connected to a cloud hosted session) and transfer times (copying projects to instances as part of scaling operations), which improves the overall end user experience.

We strongly recommend following the Reducing the File Size of Your Build guide by Unity.

Optimize Performance

The base performance of the game is the single most important factor for a high-quality streaming experience. A fine-tuned and optimized project will support a greater number of concurrent users per server which can significantly reduce costs. It will also improve the frame rate resulting in a more compelling streaming experience.

See Understanding Optimization in Unity for suggestions on optimizing your project.

Check Run State

Ensure that your game runs from a clean state on every launch, and does not require configurations or other data to be written to the local file system.

In a cloud streaming environment, different users will be accessing a game on a given cloud instance. To ensure that each user has the same experience, it is necessary that the game does not make any changes on the local file system as this may impact the experience of successive users.

Test Loading Time

To provide your on-line users with a good experience you ideally want the project to load to an initial screen in under 20 seconds. This will also ensure that various system/network timeouts are not reached when loading the project.

Prepare Your Unity Project For Cloud Deployment

  • Install & enable the PureWeb plugin
  • Create a PureWebStreaming Game Object
  • Setup game input
  • Package your game

Install & Enable the PureWeb Plugin

In order to properly stream your game through PureWeb Reality you’ll need to download the latest version of the PureWeb Platform Unity plugin.

Add the PureWeb Platform plugin package to your project through the Unity Package Manager. Under the (+) icon click 'Add package from tarball' and then select the package file you just downloaded.

After the import process is complete you'll find the PureWeb Platform plugin under the Custom header in the Package Manager window.

Create a PureWebStreaming Game Object

We will create an empty game object and associate the PureWebStreaming script with it.

Create an empty object in your scene.

You can name it anything you like in order to make your objects easier to manage. (Ours is named PlatformPlugin here.)

You can find the PureWebStreaming.cs in the Packages > PureWeb Platform > Runtime folder and attach it to the object we just created by clicking and dragging it to the object.

Alternatively, you can import it by selecting “Add Component” in the object inspector.

With these settings, your game should be able to connect to our platform when it is executed.

There is no strict rule about which object the PureWebStreaming.cs file should be attached to, or where the file should be located. You can still attach it to another existing game object if your project has special requirements, but it is strongly recommended to create a standalone object for the PureWebStreaming.cs file for proper object management.

Once the plugin is properly installed in your project, we need to adjust some settings to ensure it is configured correctly.

Game Input Setup

In order for the game to receive inputs during streaming, our platform plugin only uses the new Input System Package instead of the old Input Manager. Without this setting, you will not be able to interact with the streamed game.

Please make sure you have saved your project, or even made a backup before switching your project to the new Input System. Once you switch it to the new Input System Package, the Unity Editor will restart your project in order to enable the new package.

Once you have backed up your project, open the project settings. Under Player > Active Input Handling, select the Input System Package (New) option.

Package Your Project

Package the project and ensure that the output folder structure follows the one below before uploading it to the console.

[ProjectName.zip]
	[ProjectName]_Data
    UnityCrashHandler64.exe
    UnityPlayer.dll
    [ProjectName].exe
Unity Project Package Folder Structure

Next Steps

Now that your project is configured and packaged you’re ready to: