This part of the documentation extends the integration process of Appoxee's native library into the Unity3D world.
If your Unity project is being developed with IDE version under 5, please note that using both of our Android & iOS plugins (or any 3rd party plugin) will cause an issue known to Unity3D users, which is described in this URL : iOS build loads assembly from Assets/Plugins/Android. Why? Build fails. There is also mentioning of this (with an alternate solution) in Stack Overflow - Unity Plugin for both iOS and Android Failing AOT for iOS due to AndroidJavaObject |
UnityProjectName/Assets
Your MainCameraScript class must implement IAppoxeeCallable in order to receive the results of the API calls.
In order to initialise the Appoxee Unity Bridge, call AppoxeePlugin.CreateAppoxeeUnityBridge() , passing it your gameObject, Your SDK Key & Secret Key. Do so in your onStart() method.
Make sure the Key & Secret under your iOS Application in the Appoxee Dashboard is used for your iOS Unity App. Make sure the Key & Secret under your Android Application in the Appoxee Dashboard is used for your Android Unity App. Do not mix between them! |
The following code snippet shows the MainCameraScript class as step 1 - 5 explain :
using UnityEngine; using System; ... public class MainCameraScript : MonoBehaviour,IAppoxeeCallable<String> { ... private AppoxeePlugin unityBridge; //Keep as field/member in order to use the API. if Null, API calls will cause a crash in runtime. ... // Use this for initialization void Start () { if (myBridge == null) { Debug.Log ("UNITY: Start() calling constructor"); #if UNITY_IOS // No need to pass an SDK key & App secret on iOS. // Values should be passed via and .plist file, in the Xcode project. myBridge =AppoxeePlugin.CreateAppoxeeUnityBridge(this,"", ""); #elif UNITY_ANDROID myBridge =AppoxeePlugin.CreateAppoxeeUnityBridge(this,"SDK.Key", "App.Secret") #endif } } ... //If Application is on it's way for background / out of focus, must report deactivation for analytics void OnApplicationPause(bool pauseStatus) { if (pauseStatus) { #if UNITY_ANDROID if (unityBridge != null) { unityBridge.ReportDeactivation(); } #elif #endif } } //If Application is in focus/back in foreground, must report activation for analytics void OnApplicationFocus(bool focusStatus) { if (focusStatus) { #if UNITY_ANDROID if (unityBridge != null) { unityBridge.ReportActivation(); } #elif #endif } } ... } |
.plist
file (File -> New -> File... Recource -> Property List), and provide your SDK key. file needs to be named: AppoxeeConfig.plist.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>AppoxeeSDKID</key> <string>Your SDK ID</string></dict> </plist> |