Skip to content

Unity Plugin

Asaf Gaber edited this page Mar 13, 2017 · 23 revisions

Android

Installation

  1. Download MobFoxUnityPluginDistributables.zip and Extract it’s content into a temporary directory.
  2. In your Unity project, create folder Assets/Plugin/Android.
    Copy the following from Plugins/Android into that directory:
    AndroidManifest.xml file
    libs directory (and content)
    res directory (and content)
  3. In your Unity project, create a folder Assets/Scripts.
    Copy the following file from Scripts directory into that directory:
    MobFox.cs

    Unity Project Tree
  4. In your Unity project, create a game object called MobFoxObject.
    Attach the MobFox script to it.
  5. Fill the Mob Fox Banner Inventory Hash field with your banner inventory hash.
  6. Fill the Mob Fox Interstitial Inventory Hash field with your Interstitial inventory hash.
  7. Fill the Mob Fox Game Object Name field with the name of the game object if you use one other than MobFoxObject.

    Unity MobFox Game Object
  8. Use MobFox.ShowMobFoxBanner to display a banner ad.
  9. Use MobFox.ShowMobFoxSmartBanner to display a smart banner (full width, height 50 / 90).
  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. Find callback functions in MobFox script to handle events:
  • banner:
    • bannerReady
    • bannerError
    • bannerClosed
    • bannerClicked
    • bannerFinished
  • interstitial:
    • interstitialReady
    • interstitialError
    • interstitialClosed
    • interstitialClicked
    • interstitialFinished
  1. Its possible to change the location and dimensions of banner ads by altering the parameters passed in ShowMobFoxBanner_Android.
    (0, 0, 320, 50) are the default.
  2. By default, use of location info is disabled. To enable it, you can call MobFox.SetUseLocation(true).

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 and MobFoxUnityPlugin.mm from MobFox-iOS-SDK-Core-Lib/Plugins/Unity/, MobFoxSDKCore.bundle and MobFoxSDKCore.framework from MobFox-iOS-SDK-Core-Lib:
  • MobFoxSDKCore.bundle
  • 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

Image of MobFox.cs

  1. In your Unity project, create a game object called MobFoxObject. Attach the MobFox script to it.

Image of Unityproject

  1. Fill the ‘Mob Fox Banner Inventory Hash’ field with your MobFox hash id for banners.

  2. Fill the ‘Mob Fox Interstitial Inventory Hash’ field with your MobFox hash id for interstitials.

  3. Fill the ‘Mob Fox Game Object Name’ field with the name of the game object if you use one other than ‘MobFoxObject’.

  4. Now you can use MobFox.ShowMobFoxBanner to display a banner ad, and/or MobFox.ShowMobFoxInterstitial to display an interstitial ad.

Inside the MobFox script you can find the callback functions you can use to handle events related to the banner ads (bannerReady, bannerError, bannerClosed, bannerClicked, bannerFinished) or interstitial ads (interstitialReady, interstitialError, interstitialClosed, interstitialClicked, interstitialFinished).

You can also change the location and dimensions of banner ads by altering the parameters passed in ShowMobFoxBanner_iPhone (0, 0, 320, 50) are the default.

Clone this wiki locally