KLab Profiling for Unity helps you profile your Unity projects.
Building on the native profiler plugin API introduced with Unity 2018.2, this library
- allows you to get detailed info on Unity profiler trace events through C# callbacks,
 - automatically forwards trace events to Android's tracing API if available, and
 - allows you to handle trace events in C++.
 
If you're interested in how to handle trace events in C#, see here for the interface, and here for an example. At KLab we use the C# interface for uploading the trace data to cloud storage for later analysis in long run performance tests.
If you want to handle trace events in C++ you have to implement the trace interface and link your implementation to the library during native build. See here for the interface you have to implement. The CMake project provides a convenience option for linking your trace handler.
The library uses a utility interface for querying the ID of the execution thread and for converting UTF-16 strings to UTF-8. The interface works out-of-the-box on Win32 and POSIX platforms. You can replace the default interface by providing a custom implementation and linking to it during native build. Again, the CMake project provides a convenience option for that.
The library includes prebuilt plugins for Android, iOS, Linux, macOS, and Win32 and can be imported easily as a Unity package. It doesn't have any dependencies on other packages, but currently requires Unity 2018.2+.
Build scripts are available for building native Android, iOS, Linux, macOS, and Win32 libraries.
- Makefiles are generated with CMake. Make sure to have CMake 3.10+ installed and added to your path.
 - Unity plugin API header files have to be provided. The headers come with the Unity Editor. Either set 
UNITY_PLUGIN_API_PATHto point at the folder including the header files or opy them into './Plugin~/Vendor/UnityPluginApi/'. 
- Make sure to have the Android NDK available and 
ANDROID_NDK_ROOTas an environment variable pointing at its root folder. 
- Make sure to have XCode installed and available on the command line.
 - Clone (or download) ios-cmake into 
./Plugin~/Vendor/ios-cmake/ 
- Make sure to have build essentials available on the command line.
 
- Make sure to have XCode installed and available on the command line.
 
- Make sure to have Visual Studio (2017+) and components for building C++ installed.
 
Fixing issues and contributing directly to the code base is more than welcome. A rebase workflow is preferred over branching out.
Please stick to the Microsoft naming guidelines
when contributing C# code and document public interfaces with XML. Please also stick to the guidelines for C++.
For C, "emulate" namespaces by using underscores instead of the double colons in C++, i.e. write KLab::Profiling as KLab_Profiling.
Public C/C++ interfaces should be documented in Doxygen syntax if possible.
- Request a new feature on GitHub
 - File a bug in GitHub Issues
 
Copyright (c) KLab Inc.. All rights reserved.
Licensed under the MIT License.