Quantcast
Viewing all articles
Browse latest Browse all 1416

Unity ads , can't we show video by clicking a button?

this watch it is the method that i assigned to my button and it show the ads but it doesn't do anything from handleresult. game just keeps running, after finishing the video it should destroy the object but it doesn't.. public GameObject PlayerDestroy; public GameObject uiw; private float t; public int scene; [SerializeField] private Transform player; [SerializeField] private Transform respawnPoint; public void ModeSelect() { StartCoroutine("Wait"); } private void Start() { t = Time.time + 2; } void OnCollisionEnter(Collision obj) { Debug.Log(Time.time); if (UnityEngine.Advertisements.Advertisement.IsReady() && Time.time>t) { t = Time.time + 2f; Time.timeScale = 0f; uiw.SetActive(!uiw.activeSelf); } else { Instantiate(patlama, this.gameObject.transform.position, this.gameObject.transform.rotation); GameObject.Find("Sphere").SendMessage("Finish2"); GameObject.Destroy(PlayerDestroy); Invoke("WaitingFunction", 1); } } public void Watchit() { UnityEngine.Advertisements.Advertisement.Show("rewardedVideo", new ShowOptions() { resultCallback = HandleAdResult }); uiw.SetActive(!uiw.activeSelf); } private void HandleAdResult(ShowResult result) { switch (result) { case ShowResult.Finished: Time.timeScale = 1f; GameObject.Destroy(gameObject); break; case ShowResult.Skipped: Instantiate(patlama, this.gameObject.transform.position, this.gameObject.transform.rotation); GameObject.Find("Sphere").SendMessage("Finish2"); GameObject.Destroy(PlayerDestroy); Invoke("WaitingFunction", 1); break; case ShowResult.Failed: Instantiate(patlama, this.gameObject.transform.position, this.gameObject.transform.rotation); GameObject.Find("Sphere").SendMessage("Finish2"); GameObject.Destroy(PlayerDestroy); Invoke("WaitingFunction", 1); break; } } void WaitingFunction() { SceneManager.LoadScene(scene); }

Viewing all articles
Browse latest Browse all 1416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>