Skip to content

Unity App Integration


Collect metric data from Unity apps to analyze app performance visually.

Reading Path

Prerequisites

Note

If the RUM Headless service is enabled, the prerequisites are configured automatically, and you can integrate the app directly.

When using a local environment deployment, complete the following data receiver configuration. When using the public DataWay, you do not need to deploy DataKit yourself.

App Integration

  1. Go to RUM > Create App > Android/iOS
  2. Create two apps, one for Unity Android and one for Unity iOS, so that RUM data from the Android and iOS platforms is received separately
  3. For the app for each platform, enter the corresponding app name and app ID
  4. In "Choose an Access Method", select Agent Auto Integration or Manual Integration, and then complete "Integration Configuration".

Choose an Access Method

On the app configuration page, select "Agent Auto Integration" or "Manual Integration", and then complete "Integration Configuration". For an existing app, you can go directly to the configuration page to continue the integration.

Access Method Use Cases Entry Point
Agent Auto Integration Want a coding assistant to analyze the project and complete SDK integration Copy the prompt generated in the console and give it to the coding assistant in the app code repository for execution
Manual Integration Want to install the SDK and configure parameters yourself Confirm the data reporting method, then complete configuration according to this document and the Quick Start

Agent Auto Integration

  1. On the current app's configuration page, select "Agent Auto Integration".
  2. Copy the complete prompt from "Integration Configuration", and make sure it uses the current app's integration information.
  3. Open the coding assistant in the app code repository, paste the prompt, and let the Agent analyze the project and complete the SDK configuration according to the integration guide.
  4. Build and run the app, trigger operations such as page views, and verify in the current app's Explorer that data is received.

When using a cross-platform framework, tell the Agent the framework and target platforms, and provide the app information for each platform separately.

If the page indicates that your personal API Key or temporary authorization code is not ready, complete it as prompted, and then copy the prompt again.

Manual Integration

On the app configuration page, select "Manual Integration" and confirm the data reporting method:

  • Public DataWay: Receives RUM data directly; no need to install the DataKit collector
  • Local environment deployment: Receives RUM data after the prerequisites are met

Complete SDK installation, initialization, and verification according to Installation and Quick Start below. If an SDK configuration already exists, check and reuse it first to avoid duplicate initialization.

Installation

Source Code: https://github.com/GuanceCloud/datakit-unity

Demo: https://github.com/GuanceCloud/datakit-unity/blob/dev/Assets/Scenes

  1. Download the latest ft-sdk-unity.unitypackage
  2. Import ft-sdk-unity.unitypackage via Assets -> Import Package -> Custom Package...
  3. Add the third-party JSON parsing library "com.unity.nuget.newtonsoft-json"; you can do this in Package Manager -> Add Package by name ...
  4. Drag FTSDK.prefab to the first scene page, and initialize the SDK in the _InitSDK method in FTSDK.cs
  5. Drag FTViewObserver.prefab to other scene pages to monitor the page View lifecycle and app sleep and wake-up
  6. Use Application.logMessageReceived to listen for and convert Unity crash data and regular log data. For examples, see Quick Start and RUM Manual Tracking
Assets/Plugins
├── Android
│   ├── FTUnityBridge.java                // Android bridge
│   ├── InnerClassProxy.java              // Android Inner Setting Proxy
│   ├── ft-sdk-release.aar                // Android SDK
│   ├── gson-2.8.5.jar                    // Android SDK third-party dependency
├── iOS
│   ├── FTMobileSDK.xcframework           // iOS SDK
│   ├── FTUnityBridge.mm                  // iOS bridge
├── FTSDK.cs                              // FTSDK.prefab binding script
├── FTSDK.prefab                          // SDK initialization prefab
├── FTUnityBridge.cs                      // Unity bridge for methods on iOS, Android, and other platforms
├── FTViewObserver.cs                     // FTViewObserver.prefab binding script
├── FTViewObserver.prefab                 // View page monitoring prefab
├── UnityMainThreadDispatcher.cs          // UnityMainThreadDispatcher.prefab binding script
├── UnityMainThreadDispatcher.prefab      // Main-thread consumption queue prefab
  • If the native Android and iOS projects have already integrated the native SDK, comment out the _InitSDK method to avoid duplicate setup. For specific scenarios, see Native and Unity Hybrid Development
  • iOS Plugin Inspector Settings: FTMobileSDK.xcframework is a dynamic library, so you need to select Add to Embedded Binaries. After you select this option, Unity sets the Xcode project options so that the plugin files are copied to the final app bundle.

unity_ios_plugin_embedded

If the native SDK has already been integrated, gson-2.8.5.jar and ft-sdk-release.aar for Android, and FTMobileSDK.framework for iOS, can be removed from the Unity project.
The OkHttp request and startup time features on Android need to be used with ft-plugin. For detailed configuration, see Android SDK.

Initialization

For a minimal initialization example, see Quick Start.

For complete SDKConfig parameter descriptions, see SDK Initialization.

Detailed Configuration

Advanced Scenarios

FAQ

Add Global Variables to Avoid Field Conflicts

To avoid conflicts between custom fields and SDK data, we recommend prefixing tag names with the project abbreviation, for example, custom_tag_name. You can check the source code for the key values used in the project. If an SDK global variable has the same name as a RUM or Log variable, RUM or Log overrides the SDK global variable.

Other

Feedback

Is this page helpful?