Remote profiling

This page discusses how to connect the Unity Profiler to a worker running in a cloud deployment.

Before reading this page, make sure you are familiar with:

The Unity Profiler offers the ability to connect to an instance of your game running on a different machine. You can utilize this to profile a Unity worker running in a cloud deployment.

1. Configure your workers

The Unity Profiler connects to your worker via a host and port combination. The worker will only expose this port, if you enable the Development Build option for this worker. You can configure this via the build configuration asset.

  1. Find and open the instance of the build configuration asset in the Unity Editor Inspector.
  2. Expand the section for the worker type that you want to profile.
  3. Expand the Cloud Build Options section within that worker type.
  4. Click on the Linux tab to configure the Linux build options.
  5. Ensure that the Development box is ticked.

2. Build the workers

Now that you configured your worker correctly to allow remote profiling, you can build your workers.

  1. Select SpatialOS > Build for cloud > All workers from the Unity Editor menu to build all workers.

Alternatively, if you don’t need to rebuild all the workers, you can only build the worker type for which you enabled the Development option.

3. Upload worker assemblies & launch deployment

Use the Deployment Launcher feature module to upload the built out worker assemblies and launch a deployment.

4. Find the profiling port

At this point, your deployment should be up and running and your workers connected to that deployment.

Since your workers are running in the cloud, you need to forward the port that is exposed by those workers to your local machine in order to connect the profiler to it. Each worker should log a single message to SpatialOS detailing which port it is currently exposing.

  1. Open the deployment in the SpatialOS console.
  2. Navigate to the logs for your deployment.
  3. Look for a message similar to the following: [UnityGameLogic0:UnityGameLogic0] Unity PlayerConnection port: 55203.. If you have a lot of logs and are having trouble spotting the message, you can search for PlayerConnection in the message search box on the left hand side of the Logs page.
  4. Note down both the worker ID (UnityGameLogic0 in the example above) and the port (55203 in the example above).

Note: Since each worker will log their port, you will have more than 1 of these if you have more than one worker running! Select the worker that you are most interested in.

5. Forward the profiling port

You can forward the profiling port in two different ways, either through a Unity Editor window or using the spatial CLI directly.

6. Connect the Unity Profiler to your worker

Now all that’s left to do is to connect the Unity Profiler to your worker!

  1. Select Window > Analysis > Profiler to open the Unity Profiler window.
  2. Select the Editor button on the toolbar in the Unity Profiler window.
  3. Select the <Enter IP> option.
  4. Enter to the box that pops up.
  5. Select Connect on the popup.

The Unity Profiler is now connected to the worker that is running in the cloud deployment!

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums