This tutorial is created to show how Admix banners can be used in a dynamically generated environment that is built inside a single scene, for example when using prefab-levels.
Initially, Admix SDK was not build to support an option to add advertising content to the scene during the app runtime. We are working on the full support of this feature currently, so this tutorial rather shows a temporary workaround until the full support is introduced.
What is the idea?
The main idea is to create all ad placements in the scene in advance and move them to the desired location after the new scene part is generated.
We start with creating an app and a scene in this app that will represent our game with generated content.
Then, we place a few placements that we are going to use in our game somewhere in this scene, the location is not important.
- After the placements are added to the scene, save the changes using the “Save Placements” button.
- Go to the Developer Platform (https://app.admixplay.com/dashboard/apps) and make sure that Sandbox mode is enabled for this newly created application:
Please wait for 10 minutes before Sandbox mode activates.
- Next, we need to understand when and where we want to place ads in some part of our scene. For example, we have 2 prefab-levels. Let’s review each of these levels and transform the position/rotation of each ad and note where we want to place our ads.
For example in Level 1, we would like to place our “Big Banner” with the following position and rotation values:
In Level 2 the same big banner will be here:
- Now, when we understand where we want to place our banners, we can simply use transform.position and transform.Rotate methods wherever the time comes to add ads to the game.
For example, for Level 1:
//For our big banner
BigBanner.transform.position = new Vector3(25.89f, -3.12f, 4.08f);
BigBanner.transform.Rotate(0, 0, 0, Space.Self);
// if it is under the Start() - BigBanner.transform.rotation = Quaternion.Euler(0, 0, 0);
//And for our small banner
banner.transform.position = new Vector3(-2.7f, 7.01f, 5.2f);
banner.transform.Rotate(0, -0.5f, 0, Space.Self);
// if it is under the Start() - banner.transform.rotation = Quaternion.Euler(0, -0.5f, 0);
And for Level 2:
BigBanner.transform.position = new Vector3(3.33f, -3.12f, -82.37f);
BigBanner.transform.Rotate(0, 90.3f, 0, Space.Self);
banner.transform.position = new Vector3(4.94f, 7.01f, -64.77f);
banner.transform.Rotate(0, -95.77f, 0, Space.Self);
Here is how this works:
To ensure that the content of the placements changes through the level and they generate more income, we refresh them on a regular basis whenever a new content for the placements is available. This is a new feature that has been introduced starting with the plugin version 188.8.131.52.
Please note, that due to a known issue, in version 1.9, 2.0 Admix banners cannot be used as a part of prefab.