Using Easy Mobile

Overview

Using Easy Mobile involves 3 steps:

  1. Configuring the plugin using the built-in Settings interface
  2. Initializing the plugin runtime
  3. Making appropriate API calls from script (or using visual scripting actions)

After importing Easy Mobile, there will be a new menu added at Window > Easy Mobile from which you can open the Global Settings interface to configure modules as well as access other resources.

Global Settings

The Global Settings interface is the only place you go to configure the plugin. Here you can control everything including toggling module on or off, providing ads credentials, adding leaderboards, creating a product catalog, etc.

All these settings are stored in the EM_Settings object, which is a ScriptableObject created automatically after importing the plugin and is located at Assets/EasyMobile/Resources. You can also access this EM_Settings class from script and via its properties accessing each module settings in runtime.

Initializing

You must always initialize Easy Mobile before using its API.

Since the initialization must be done before the Easy Mobile API can be used, it is advisable to do it as soon as your app launches. This will also allow automatic services such as ad loading to start soon and the ads will be more likely available when needed. Practically, this means attaching the initializing script to some game object in the first scene of your app.

To initialize simply call the Init method of the RuntimeManager class. This method is a no-op if the initialization has been done so it's safe to be called multiple times. You can also check if Easy Mobile has been initialized using the IsInitialized method.

using UnityEngine;
using System.Collections;
using EasyMobile; // include the Easy Mobile namespace to use its scripting API

public class EasyMobileInitializer : MonoBehaviour
{
    // Checks if EM has been initialized and initialize it if not.
    // This must be done once before other EM APIs can be used.
    void Awake()
    {
        if (!RuntimeManager.IsInitialized())
            RuntimeManager.Init();
    }
}

Scripting API

After initializing Easy Mobile you can use its scripting API, which is written in C#. Note that the API is put under the namespace EasyMobile so you need to add the following statement to the top of your scripts to access it.

// Put this on top of your scripts to use Easy Mobile scripting API
using EasyMobile;

Easy Mobile's API is cross-platform so you can use the same code for both iOS and Android. You can find the API reference here.

Testing

Most of Easy Mobile's functionalities are mobile-specific which may not work properly within the Unity editor. Therefore you should always perform testing on actual iOS or Android devices.

Using the Demo App

Easy Mobile comes with a demo app that you can use to quickly test each module's operation after configuring, even before writing any code! The demo app is located at folder Assets/EasyMobile/Demo. Its scenes are in the subfolder Scenes, you can build all scenes or only scenes that you want to test. Its scripts are in the subfolder Scripts, which you can refer to for an example of how Easy Mobile API can be used.

Integration with 3rd-party SDKs

Easy Mobile works with a wide range of 3rd party SDKs for its functionalities, e.g. the Google Mobile Ads plugin for AdMob ads, the Google Play Games plugin for game services, the OneSignal plugin for push notifications, etc. You import these 3rd party SDKs into your project to use them with certain modules of Easy Mobile. Once a relevant plugin is imported, Easy Mobile automatically detects its presence and updates its settings UI accordingly to allow you access to the corresponding module or feature. Detailed instructions will be included in the chapter dedicated to each module.

If you no longer want to use a 3rd party SDK, remember to disable the Easy Mobile module that requires it before removing the SDK to avoid errors. You can then re-enable the module if needed.

Requirements

Easy Mobile requires:

  • Unity 2017.4.19 or newer.
  • iOS 8.0 or newer.
  • Android 4.0 (API Level 14) or newer.

results matching ""

    No results matching ""