Advanced

From here you can add more functionality to the AdInMo SDK within your game. This section contains a range of functions that you can add and will require editing C# scripts.

Extra Revenue

Between levels, call the function below to earn extra revenue. See the example scene called ExampleDialog.unity to see how to call it and register a callback to know when this dialog is done.

1
AdinmoManger.ShowDialog()

Callback Function

For added control, there is a callback function you can register. This is useful for hiding an object until the replacement textures have been downloaded and applied, thus avoiding a visual pop.

1
AdinmoManager.SetOnReadyCallback()

Your delegate function must be of the form:

1
void MyDelegate( string message );

Background Colour

If the placement doesn’t fill the object its applied to, you may need to alter the background colour. We provide a call to get the background colour set by the advertisement so you can update the object as required.

1
Color AdinmoTexture.GetBorderColor()

Rotate Textures

You can rotate which textures are displayed on which placements by calling the following function, e.g. between levels.

1
void AdinmoManager.CycleTextures()

Temporarily Disable AdInMo Processes/Traffic

If you want to temporarily disable all AdInMo processing and network traffic, you can call:

1
AdinmoManager.Pause()

To resume normal operations, call:

1
AdinmoManager.Resume()

Dynamic Placements

AdInMo supports the concept of dynamic ads, these are ad placements that are created programmatically rather than through the Unity editor.

This allows AdInMo to support situations where a game developer programmatically creates objects in the game, our SDK supports the concept of then creating the ad unit programmatically once the object has been created.

Here’s a simple example of how this works using the AdInMo Unity SDK.

  1. Create a game object (image, quad or sprite) adding the ‘Adinmo Texture’ component with a placement key.

  2. Next, create a prefab of the placement game object by dragging it into the assets window and removing the original from the hierarchy.

  3. Copy and paste the code below these steps into a new C# script, and save it.

  4. Create an empty game object and add the script onto it.

  5. Now select and drag the placement prefab (step 2) into the the example script.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
using UnityEngine;

public class InstantiationExample : MonoBehaviour
{
    // Reference to the Prefab. Drag a Prefab with an AdInMo Texture component attached to it into this field in the Inspector.

    public GameObject myAdinmoPrefab;

    // This script will simply instantiate the Prefab when the game starts.

    void Start()
    {
        // Instantiate at position (0, 0, 0) and zero rotation.

        Instantiate(myPrefab, new Vector3(0, 0, 0), Quaternion.identity);
    }
}