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:
- In Unity Editor, go to Assets > Import Package > Custom Package...
- Select the downloaded
UjuUnitySDK.unitypackagefile - Click Import to import all files
2. Configure Player Settings
Android Settings
- Go to Edit > Project Settings > Player > Android > Other Settings
- Set Minimum API Level to 26 or higher
- Set Target API Level to the latest API level
- Enable Custom Main Gradle Template and Custom Gradle Properties Template
- 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
- Go to Edit > Project Settings > Player > iOS > Other Settings
- Set Minimum iOS Version to 10.0 or higher
- 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
- In Unity Editor, go to UJU > Settings
- 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:
