Unity SDK Integration

893ad6d-Unity_icon.png

Current SDK Version: 3.21.1

 

Introduction

This guide is intended for developers who are integrating the FairBid SDK with a Unity app. After you have integrated the SDK, you must choose the relevant ad format and follow the steps for implementing that format.

Prerequisites

  • Android 4.1 (API level 16)+ (when building for Android)
  • iOS 9.0+ (when building for iOS)
  • Unity 2018 LTS or later

Important

  • The FairBid Unity SDK can only build iOS projects from a Mac - you cannot build your Xcode project on Windows.
  • All Fyber SDKs and supported mediated networks work in conjunction with Android's 64-bit architecture.

Integration Methods

Fyber supports two methods for the integration of Unity:

  1. Integration through Unity's Package Manager
  2. Importing FairBid Unity Plugin Raw Package

Integrating Through Unity's Package Manager

FairBid Unity Plugin is provided as a package in the NPM package registry. This package is imported using Unity Package Manager. To import this package, you need first to add the following entries inside your manifest.json file, which you can find under the Packages folder:

  • An entry under scopedRegistries, so that unity knows where to search when adding the FairBid Unity Plugin dependency. This entry points to the NPM package registry:
{
  …
  "scopedRegistries": [
      {
          "name": "npmjs",
          "url": "https://registry.npmjs.org/",
          "scopes": [
              "com.fyber.fairbid.unity"
          ]
      }
      …
    ],
  …
}
  • An entry under dependencies, which references the FairBid Unity Plugin version that you intend to integrate:
{
  …
  "dependencies": {
      "com.fyber.fairbid.unity": "3.21.1",
      …
  }
  …
}

Save the changes and open your Unity 3D Project. The Unity Package Manager will resolve the dependencies and now Fyber FairBid should be integrated in the project. You can also cross check the integration of Fyber FairBid by going to the “Window” toolbar menu of Unity 3D and clicking on "Package Manager". You should see the following window pop-up with FairBid under the section Fyber and the FairBid SDK version:

Screenshot_2021-08-17_at_12.01.07.png

You will also have the possibility to change the version of the FairBid Unity Plugin that you are integrating through the Unity Package Manager.

Important

The integrated FairBid Unity Plugin is a lightweight dependency. You must add the sources of the native FairBid SDKs for the platform you are building. Follow the instructions for the platform specific setups below.

Importing FairBid Unity Plugin Raw Package

Follow the instructions below to manually download the SDK.

Manual Download

 

Removing Current Plugin

If you are updating the Plugin, first make sure there is no trace of the previous version of the FairBid Plugin.

Simply remove the FairBid folder. This is a fail-safe way to ensure no legacy file is left behind:

67626ea-Unity1.png

If your current FairBid Plugin pre-dates version 3.4.1 refer to Migrating from the Old to New Structure below to ensure it is correctly removed.

Importing New Plugin

  1. Download the FairBid SDK
  2. Unzip the downloaded files
  3. Add the FairBid.unitypackage to your open Unity project

OS Specific Setup

Android Specific Setup

Note

This step is not required if you are integrating using the Importing FairBid Unity Plugin Raw Package

The FairBid Android SDK dependency must be added to your project.

You must declare the following dependency in your mainTemplate.gradle file, in exactly the same way that you would for a native integration:

dependencies {
    implementation 'com.fyber:fairbid-sdk:3.21.1'
    …
}

iOS Specific Setup

Note

This step is not required if you are integrating using the Importing FairBid Unity Plugin Raw Package

The FairBid iOS SDK dependency must be added to your project.

You must Build and run your Unity 3D project and then add the Fyber FairBid iOS SDK pod in your Podfile.

Recent versions of Unity 3D (since 2019.3) create a target named UnityFramework. If this is your case and you can see this target inside your Podfile, then add the FairBid iOS SDK dependency under it. Otherwise, add it to the standard target. Then run the pod install command, in exactly the same way you would for a native integration:

# You might not have this target but a test app target instead,
# depending on the Unity3D version used target 'UnityFramework' do # Pods for UnityFramework pod 'FairBidSDK', '~> 3.21.1' end

Back to Top ⇧