-
Notifications
You must be signed in to change notification settings - Fork 0
Profiling mods
Written by Marioalexsan
You will need to have Unity Editor 2022.3.62f2 installed, and a project of any kind available (a blank project will do).
To profile the game, you will first need to switch to the debug mode runner. The steps to do that are:
- Go to ATLYSS's install path, and backup your current
ATLYSS.exeandUnityPlayer.dll- for example into anUnityReleasePlayerfolder. - Go to your Unity Editor install path, for example
D:\Program Files\Unity Editors\2022.3.62f2\Editor. - Go to
Data\PlaybackEngines\windowsstandalonesupport\Variations\win64_player_development_mono. - Copy
WindowsPlayer.exeandUnityPlayer.dllinto ATLYSS's install path, and renameWindowsPlayer.exeintoATLYSS.exe. - Go to ATLYSS's install path, then to
ATLYSS_Data/boot.config. - Add
player-connection-debug=1as a new line to the configuration. -
(Optional) Backup the debug mode runner (i.e. the renamed
ATLYSS.exe,UnityPlayer.dlland the modifiedboot.config) into a separate folder likeUnityDebugPlayerfor easy access - Steam will try to replace the runner whenever the game updates, so you'll have to repeat these steps whenever that happens.
You should now be able to connect a debugger (VS / Rider) or a profiler to the game when it runs. To start the profiler:
- Open Unity Editor with any project (for example a blank project).
- Go to
Window => Analysis => Profiler (Standalone Process); this will launch the profiler in a separate window. - Launch the game.
- In the profiler's target selection next to the record button, select
Local => WindowsPlayer => the game instance identified by the device name, local IP and port. - Stop / start again the recording by pressing Record.

If you've done everything right, you should see something like this. The profiler will be able to show you the time spent within the various lifecycle callbacks of the game's scripts, and other data such as GUI processing, memory usage, etc.
This gives you a high level overview of CPU usage, it can't go deeper than that since the profiler can't do deep instrumentation for a finished build. However, in some cases you'll want to use markers to segment your code into chunks and analyze each of them separately. To do so, you'll need to do the following:
- Add to your mod's
.csprojthe following conditional definition, this allows profiler markers to actually work and not be skipped by the compiler due toConditionalAttribute. If you want, you can make it apply both to Debug and Release builds by removing theCondition:
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DefineConstants>
<!--
-->ENABLE_PROFILER;<!-- For Unity's ProfileMarkers to actually emit calls
-->
</DefineConstants>
</PropertyGroup>Example usage: ModAudio.csproj
- In your code, declare a new marker somewhere. For example:
private static readonly ProfilerMarker _executeUpdate = new ProfilerMarker("ModAudio Update() execute script updates");- Surround a code block you want to segment with Begin() and End(). For example:
if (!string.IsNullOrEmpty(pack.Config.PackScripts.Update) && pack.Script != null)
{
_executeUpdate.Begin();
pack.Script.ExecuteUpdate();
_executeUpdate.End();
}Example usage: ModAudio/AudioEngine.cs
- Recompile and install the mod, then launch the game and attach the profiler.
All available development runner counters as provided by ProfilerRecorderHandle.GetAvailable().
debug_mode_counters_available.txt