- Home /
UnityAds work in Editor, but not on the device
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");
}
}
}
The exact same thing happened to me today, I was just about to post a question and this was asked 2 $$anonymous$$utes ago. It was working this morning although the rewards ad I had added to be called at the press of a button was kind of slow, then slowly it stopped working as did my normal ad. The only things I could see that could have been problems is that it says in my console that the UnityAdsEditor : Initialize is false. Although I have manually Initialized it on start. Although another thing may be a problem is the platform. I have selected Android only but at the bottom and on advance it shows it is supported by both platforms and my project on my dashboard it also has both and shows the ID for both platforms. Hopefully this additional information can help!
Now I have another problem, video ads are showing , but I have the same problem as you , rewardvideo won't show . I use that code that is in unity services for rewarded video , work in editor ,but not on device. So that was your problem ? You solved it ?
Well I will try to fix it tomorrow. I will update to the latest version of unity and now that you mention it could be a fix. I hope I won't have to try other ad services because this was much easier than those and it was integrated into unity. If I get an updates I will tell you thanks.
Your answer
Follow this Question
Related Questions
Should my Unity Ads ECPM be 0? 2 Answers
How do I limit video ads? 0 Answers
Black screen came after closing a unity ad., A Black Screen come out after closing Unity Ad. 0 Answers
Unity Ads Banner not working. 0 Answers
My game Id Android doesnt work. 0 Answers