Skip to content

Unity Preparation

Development Environment Requirements

  • Unity Editor: 2019.4 LTS or higher
  • Windows: Windows 7 or higher
  • macOS: macOS 10.12 or higher
  • Android SDK: Android 8.0 or higher (for Android builds)
  • iOS SDK: iOS 10.0 or higher (for iOS builds)

Project Configuration

1. Import SDK Package

Download the UJU Unity SDK package from the developer backend and import it into your Unity project:

  1. In Unity Editor, go to Assets > Import Package > Custom Package...
  2. Select the downloaded UjuUnitySDK.unitypackage file
  3. Click Import to import all files

2. Configure Player Settings

Android Settings

  1. Go to Edit > Project Settings > Player > Android > Other Settings
  2. Set Minimum API Level to 26 or higher
  3. Set Target API Level to the latest API level
  4. Enable Custom Main Gradle Template and Custom Gradle Properties Template
  5. Add necessary permissions to AndroidManifest.xml:
xml
<!-- Required permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- Optional permissions -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

iOS Settings

  1. Go to Edit > Project Settings > Player > iOS > Other Settings
  2. Set Minimum iOS Version to 10.0 or higher
  3. Add necessary permissions to Info.plist:
xml
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to provide you with personalized ads.</string>

3. Configure UJU Settings

  1. In Unity Editor, go to UJU > Settings
  2. Fill in the following fields:
    • App ID: Your UJU App ID
    • App Key: Your UJU App Key
    • Test Mode: Enable during development

SDK Initialization

Initialize the SDK in your game's startup script:

csharp
using UnityEngine;
using UjuAdSDK;

public class GameManager : MonoBehaviour
{
    private void Start()
    {
        // Initialize UJU SDK
        InitializeUjuSDK();
    }
    
    private void InitializeUjuSDK()
    {
        UjuAdInitConfig config = new UjuAdInitConfig
        {
            appId = "YOUR_APP_ID",
            appKey = "YOUR_APP_KEY",
            isDebug = true
        };
        
        UjuAdSDKManager.Instance.InitSDK(config, (success, error) => {
            if (success)
            {
                Debug.Log("UJU SDK initialized successfully");
                // SDK initialized successfully, can start loading ads
            }
            else
            {
                Debug.LogError("UJU SDK initialization failed: " + error);
            }
        });
    }
}

Testing

Test Mode

Enable test mode during development:

csharp
// Enable test mode
UjuAdSDKManager.Instance.SetTestMode(true);

Test Devices

Add test devices to avoid invalid clicks:

csharp
// Add test device
UjuAdSDKManager.Instance.AddTestDevice("YOUR_DEVICE_ID");

Best Practices

  • Early initialization: Initialize the SDK as early as possible in the game startup process
  • Platform-specific settings: Configure platform-specific settings correctly for Android and iOS
  • Error handling: Implement proper error handling for ad loading failures
  • Ad preloading: Preload ads before they need to be displayed
  • Frequency control: Control ad display frequency to avoid user annoyance
  • Test thoroughly: Test ads on both Android and iOS platforms

Common Questions

Q: Why isn't the SDK initializing?

A: Possible reasons:

  • Incorrect App ID or App Key
  • Network connection issues
  • Unity version incompatibility
  • Missing required permissions
  • Incorrect platform settings

Q: How to get the device ID for testing?

A: You can find the device ID in the Unity Console logs when running the app with test mode enabled.

Q: What platforms are supported by UJU Unity SDK?

A: The UJU Unity SDK supports:

  • Android
  • iOS
  • Standalone (Windows/macOS)

Next Steps

After completing the preparation work, you can proceed with: