I want to add admob into my game and don't want to request/load the ad everytime I change the scenes. I tried to solve that with "DontDestroyOnLoad", but somehow the object where my AdManager script is attached to, will be destroyed, when I change between other scenes.
This is the code, I wrote into my AdManager script.
private static bool created = false;
...
void Awake()
{
if (!created)
{
DontDestroyOnLoad(gameObject);
created = true;
}
else
{
Destroy(gameObject);
}
}
The AdManager script is getting called in the main menu (when I start the game). When I press the "Start"-Button, the AdManager script should be available in the other scenes, but it just disappears/gets destroyed.