Skip to content

Unity Plugin

shahafss edited this page Sep 13, 2017 · 23 revisions

Android

Installation

  1. Download or clone whole SDK-Plugins project and Extract SDK-Plugins/Unity content into a temporary directory.
  2. In your Unity project, create folder Assets/Plugins/Android.
    Copy the following from SDK-Plugins/Unity/MobFox-Unity-Demo/Assets/Plugins/Android into that directory:

  • AndroidManifest.xml file
  • libs directory (and content)
  • res directory (and content)
  1. In your Unity project, create a folder Assets/Scripts.
    Copy the following file from Scripts directory into that directory:
    MobFox.cs

    Unity Project Tree
  2. In your Unity project, create a game object called MobFoxObject.
    Attach the MobFox script to it.
  3. Fill the Mob Fox Banner Inventory Hash field with your banner inventory hash.
  4. Fill the Mob Fox Interstitial Inventory Hash field with your Interstitial inventory hash.
  5. Fill the Mob Fox Game Object Name field with the name of the game object if you use one other than MobFoxObject.
  6. Fill the Top, Left fields with your location preferences.
  7. Fill the Width, Height fields with your banner size (default 320x50).

    Unity MobFox Game Object
  8. Use MobFox.ShowMobFoxBanner to display a banner ad.
  9. Use MobFox.HideMobFoxBanner, MobFox.UnhideMobFoxBanner to hide / unhide a banner ad.
  10. Use MobFox.CreateAndShowMobFoxInterstitial to display a interstitial ad.
  11. To only load the interstitial use MobFox.CreateMobFoxInterstitial.
    show the interstitial in the interstitialReady event with the MobFox.ShowMobFoxInterstitial method.
  12. To load a native ad use MobFox.ShowMobFoxNative
  13. Find callback functions in MobFox script to handle events:
  • banner:
    • bannerReady
    • bannerError
    • bannerClosed
    • bannerClicked
    • bannerFinished
  • interstitial:
    • interstitialReady
    • interstitialError
    • interstitialClosed
    • interstitialClicked
    • interstitialFinished
  • native:
    • nativeReady (see demo code for how to get the native components from the passed param)
    • nativeError
  1. By default, use of location info is disabled. To enable it, you can call MobFox.SetUseLocation(true).

Demo app

  1. Unity with MobFox demo app is available. With Banner, Interstitial and native test ads integrated, its highly recommended to use this as reference.

iOS

This feature lets you develop with unity and use MobFox's SDK.

Run Unity Demo project : https://github.com/mobfox/MobFox-iOS-SDK-Core-Lib/tree/master/Plugins/UnityDemo

Instructions:

  1. In your Unity project, create a folder Assets/Plugin/iOS. Copy to that directory the files MobFoxUnityPlugin.h , MobFoxUnityPlugin.mm and MobFoxSDKCore.framework from SDK-Plugins/Unity/MobFox-Unity-Demo/Assets/Plugins/iOS/:
  • MobFoxSDKCore.framework
  • MobFoxUnityPlugin.h
  • MobFoxUnityPlugin.mm
  1. In your Unity project, create a folder Assets/Scripts. Copy the following file from Scripts directory into that directory:
    MobFox.cs

    Unity Project Tree

  1. Make sure AdSupport.framework and libz.dylib are included in your project's frameworks.
  2. In your Unity project, create a game object called MobFoxObject.
    Attach the MobFox script to it.
  3. Fill the Mob Fox Banner Inventory Hash field with your banner inventory hash.
  4. Fill the Mob Fox Interstitial Inventory Hash field with your Interstitial inventory hash.
  5. Fill the Mob Fox Game Object Name field with the name of the game object if you use one other than MobFoxObject.
  6. Fill the Top, Left fields with your location preferences.
  7. Fill the Width, Height fields with your banner size (default 320x50).

    Unity MobFox Game Object
  8. Use MobFox.ShowMobFoxBanner to display a banner ad.
  9. Use MobFox.HideMobFoxBanner, MobFox.UnhideMobFoxBanner to hide / unhide a banner ad.
  10. Use MobFox.CreateAndShowMobFoxInterstitial to display a interstitial ad.
  11. To only load the interstitial use MobFox.CreateMobFoxInterstitial.
    show the interstitial in the interstitialReady event with the MobFox.ShowMobFoxInterstitial method.
  12. To load a native ad use MobFox.ShowMobFoxNative
  13. Find callback functions in MobFox script to handle events:
  • banner:
    • bannerReady
    • bannerError
    • bannerClosed
    • bannerClicked
    • bannerFinished
  • interstitial:
    • interstitialReady
    • interstitialError
    • interstitialClosed
    • interstitialClicked
    • interstitialFinished
  • native:
    • nativeReady (see demo code for how to get the native components from the passed param)
    • nativeError
  1. By default, use of location info is disabled. To enable it, you can call MobFox.SetUseLocation(true).

Demo app

  1. Unity with MobFox demo app is available. With Banner, Interstitial and native test ads integrated, its highly recommended to use this as reference.

Clone this wiki locally