I want to add button to game which purpose is to reward developer by watching ad (ui button click).But video loads after 5-6 seconds. What to do to show ads right away when you click on button , without waiting ???
It should show immediately. Please share code, or see what differences you have compared to our “reference implementation” in GitHub - Unity-Technologies/unity-ads-engineintegration-test or https://github.com/Unity-Technologies/unity-ads-assetstore-test
/Rasmus
I have Admob video here and Unity Video Ad
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
using admob;
public class BtnSc : MonoBehaviour
{
private void Start()
{
Admob.Instance().loadInterstitial();
}
public void Click()
{
if (Advertisement.IsReady())
{
Advertisement.Show();
}
else if (Admob.Instance().isInterstitialReady())
{
AdsManager.Instance.ShowVideo();
}
else
{
Advertisement.Show();
}
}
}
In Editor Unity Ads are showing right away when i click on button , but not on Android device(on device after few seconds as i said )
How much time are you giving Ads SDK to initialize? Remember it has to get response from server, likely cache videos etc before ad is ready to show.
/Rasmus
It takes 12 seconds for ad to show(I counted now), but new problem came up . With this script when ball hits wall bottom game reloads and when the game over is counted 12th time it should show ad. It worked till now, now when i played suddendly there is no ad on 12th gameover , game just stops on 12.(Admob ads)
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class BallScript : MonoBehaviour
{
public Vector2 startForce;
static int times = 0;
public Text timesText;
public Vector3[] positions;
public Rigidbody2D rb;
void Start()
{
int randomNumber = Random.Range(0, positions.Length);
transform.position = positions[randomNumber];
times = PlayerPrefs.GetInt("PlayedInRow:", times);
rb.AddForce(startForce, ForceMode2D.Impulse);
}
void Update()
{
PlayerPrefs.SetInt("PlayedInRow", times);
timesText.text = "PlayedInRow:" + times.ToString();
}
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.name == "wall_bottom")
{
times++;
if (times == 12)
{
AdsManager.Instance.ShowVideo();
}
SceneManager.LoadScene("wfvv");
One guess is that since you store and load the value of times using PlayerPrefs.SetInt() /PlayerPrefs.GetInt(), you start on a number higher than 12 next time you start game. Perhaps add Debug.Log() messages to you code to see if this is the case.
/Rasmus
Well no , counter resets to 0 when you quit the game. I don’t know origin of the problem , yesterday worked fine :((