How to debug and profile a Unity-Vortex distributed simulator
Vortex distributed simulators using Unity as a renderer use VortexUnityApp.exe as a standard application to run the simulator. We provide a development version, VortexUnityAppDev.exe, that can be used to debug and profile a Unity node in a distributed simulator.
Setting up the Unity node for debugging and profiling
- In the Vortex Director, edit your simulator's configurations.
- In the Executable column in the node table, choose "Vortex Unity Profiler" instead of "Vortex Unity" for your graphics node.
- Start your simulator.
When choosing Vortex Unity Profiler, the simulator runs as usual. However, it is possible to connect the running application to the Unity Profiler using the Unity Editor.
Connect the Unity node to the Unity profiler
Start the Unity editor and press Ctrl-7 to open the profiler window, or select Window → Analysis → Profiler
In the Profiler Window, press the Playmode combo box and select the appropriate WindowsPlayer element. It is possible to profile a remote process by entering the IP of the computer running the process.
The profiling session should now be active, e.g. with Timeline view on bottom panel
Profiler with Hierarchy view on the bottom panel
Frame Debugger can also be useful by Window → Analysis → Frame Dubugger → Enable
For more information, consult the Unity documentation of the Profiler window.
Debug scripts at runtime
It is also possible to debug custom scripts using the Profiler version of VortexUnityApp. Open VisualStudio and select Debug→Attach Unity Debugger and you will be able to connect to the running process. It is also possible to connect to a remote process, on another computer. Visual Studio must have the Unity plugin installed for this feature.
You are then attache to the process. If the symbols are loaded (pdb), you will be able to put breakpoints and inspect variables during runtime.
One important point, to debug scripts that are in a separate dll (e.g. SimulationProductsClassLibrary.dll) the pdb must be generated in the portable format. This is set in Visual Studio projects Build settings.