Prepare your Unity application
If your application is built using Unity, follow these steps to prepare your application for tracing:
- Check your SDK and NDK versions
- Add the interceptor library to your project (Android 9 or earlier)
- Player and build settings
Check your SDK and NDK versions
Check that you are using the Unity recommended Android SDK and Android NDK versions in the Unity editor.
- On Windows and Linux, select Edit > Preferences > External Tools.
- On macOS, select Unity > Preferences > External Tools.
If the checkboxes are selected, they are installed. Otherwise, you can add them as modules. See https://docs.unity3d.com/Manual/android-sdksetup.html for more information.
Add the interceptor library to your project
To enable Graphics Analyzer to trace your application on devices running Android 9 or earlier, you need to add the Arm interceptor library to your Unity project. The interceptor library intercepts and collects information about the OpenGL ES and EGL function calls made by the application. Unity detects the presence of the interceptor library and automatically loads it when you build the application. Follow these steps to add the library and set Unity’s player and build settings to use it.
libMGD.so is provided in your Arm Mobile Studio package:
Two versions of the library are provided:
- For 64-bit applications, use the library file located in the
- For 32-bit applications, use the library file located in the
Note: You can package one or both interceptor libraries depending on the requirements of your application.
- Copy the required interceptor library,
libMGD.so, into the Unity project directory
Assets/Plugins/Android/, creating this directory if it does not already exist.
If you are packaging both interceptor libraries:
- Create two directories in the
Assets/Plugins/directory. For example,
- Create a directory called Android in each of these directories.
- Copy each
libMGD.sofile into the appropriate
- Create two directories in the
- Select the library in Unity and set the following attributes in the Inspector:
- Under Select platforms for plugin, select Android
- Under Platform settings, set the CPU architecture to ARM64 for 64-bit applications, or ARMv7 for 32-bit applications.
- Click Apply.
Player and build settings
Set the following in Unity to build a debuggable application that Graphics Analyzer can trace.
- Select File > Build Settings, then select Player Settings.
- Under Identification, set Target API Level to the required Android version.
Note: By default, Target API Level is set to the latest version of the Android SDK tools that you have installed. If you change to a lower API level, ensure that you have the SDK tools for that version installed, and be aware that if you want to build for a higher API version later, you will need to change this setting accordingly.
- Under Configuration, set the following options to build a 64-bit application:
- Set the scripting backend in Unity to work with 64-bit targets. SetScripting Backend to IL2CPP. For more information about IL2CPP, refer to the Unity documentation.
- Under Target Architectures, select ARM64.
To build a 32-bit application:
- Leave the scripting backend at its default setting, Mono.
- Under Target Architectures, select ARM7.
- Close the Player Settings. In the Build Settings, select the Development Build checkbox. This option ensures that your application is marked as debuggable in the Android application manifest.
- Select Build and Run to build your APK and install it on your device in one step. Alternatively, select Build to build the APK and then install it on your device using Android Debug Bridge:
adb install -r YourApplication.apk