This is a guide on how to enable debugging in a standalone Unity Player.
Debugging a managed worker in a cloud deployment is not supported.
Before reading this guide, make sure you are familiar with:
The .NET debuggers connect to your worker via a host and port combination. The Unity will only expose this port if you enable the
Allow Debug options for this worker. You can configure this via the build configuration asset.
- Find and open the instance of the build configuration asset in the Unity Editor Inspector.
- Expand the section for the worker type that you want to profile.
- Expand the
Local Build Optionssection within that worker type.
- Select the tab that corresponds to the platform you would like to debug. For example, to run the worker on
Win x64tab to configure the
- Ensure that both the
Allow Debugboxes are ticked.
Now that you've configured your worker to allow debugging, you can build your workers.
Select SpatialOS > Build for local > 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
Allow Debug options.
In order to debug your worker, it must be running.
For example, if you wanted to debug a standalone UnityClient worker, you would select Spatial OS > Launch standalone client from the Unity Editor menu. Once launched, you will see this dialog:
Do not dismiss the dialog yet!
We need to attach the .NET debugger; follow the rest of the guide to see how!
Once the debugger is attached to the Unity process, click OK on this dialog.
- Open Run > Attach Unity Process...
- Select the process that contains your game name and select OK.
- Open Debug > Attach Unity Debugger
- Select the Project with your game name and click OK.
Rider/Visual Studio should now be attached to the Unity process and you can debug as normal.
Updated about a year ago