using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Advertisements;
public class BallScript : MonoBehaviour
{
public void ShowAd()
{
if (Advertisement.IsReady())
{
Advertisement.Show();
}
}
public Vector2 startForce;
static int times = 0;
public Text goverText;
public Vector3[ ] positions;
public Rigidbody2D rb;
void Start()
{
int randomNumber = Random.Range(0, positions.Length);
transform.position = positions[randomNumber];
times = PlayerPrefs.GetInt(“Played:”, times);
rb.AddForce(startForce, ForceMode2D.Impulse);
}
void Update()
{
PlayerPrefs.SetInt(“Played:”, times);
goverText.text = “Played:” + times.ToString();
}
void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.name == “wall_bottom”)
{
times++;
if (times==19)
{
ShowAd();
}
SceneManager.LoadScene(“wfvv”);
}
}
}
If it works in editor, it should also work on device. Please check device log (using “adb logcat -v time UnityAds:V *:S”) to see if it contains relevant information, e.g. if you get any campaigns. Look for calls to “adserver.unityads.unity3d.com ”
/Rasmus
rasmus-unity:
If it works in editor, it should also work on device. Please check device log (using “adb logcat -v time UnityAds:V *:S”) to see if it contains relevant information, e.g. if you get any campaigns. Look for calls to “adserver.unityads.unity3d.com ”
/Rasmus
“adb logcat -v time UnityAds:V *:S” where should I put this line ?
Sorry, command line. adb is the Android “debugger” command. Above command will show messages from Unity Ads SDK only
Still nothing…
When I’m installing apk file to my phone it demands internet access , but in game no ads :((
Now is working , but seems that video won’t be shown everytime when I call ads
Ok, but as said, the device log should contain information which can help you to figure out why you’re not getting ads everytime.
/Rasmus
Which command did you write at command line? E.g. see Strumento a riga di comando Logcat | Android Studio | Android Developers for Google’s documentation on using adb.
adb logcat -v time UnityAds:V *:S I wrote this command line