Şimdi Ara

Unityde adbomun sahne geçişi sonrası çalışmaması

Bu Konudaki Kullanıcılar:
2 Misafir - 2 Masaüstü
5 sn
5
Cevap
0
Favori
610
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
0 oy
Öne Çıkar
Sayfa: 1
Giriş
Mesaj
  • Oyuna admo ile ödüllü reklam koydum ama sahne değiştirip geri gelindiğinde reklam açılıyor fakat reward yüklenmiyor. neden olabilir kodu şöyle:

    public string Rewarded_ID;
    public GameObject repanel;

    RewardBasedVideoAd rewardBasedVideo;

    void Start () {

    rewardBasedVideo = RewardBasedVideoAd.Instance;
    repanel.SetActive(false);
    RequestRewardBasedVideo();

    // RewardBasedVideoAd is a singleton, so handlers should only be registered once.
    this.rewardBasedVideo.OnAdLoaded += this.HandleRewardBasedVideoLoaded;
    this.rewardBasedVideo.OnAdFailedToLoad += this.HandleRewardBasedVideoFailedToLoad;
    this.rewardBasedVideo.OnAdOpening += this.HandleRewardBasedVideoOpened;
    this.rewardBasedVideo.OnAdStarted += this.HandleRewardBasedVideoStarted;
    this.rewardBasedVideo.OnAdRewarded += this.HandleRewardBasedVideoRewarded;
    this.rewardBasedVideo.OnAdClosed += this.HandleRewardBasedVideoClosed;
    this.rewardBasedVideo.OnAdLeavingApplication += this.HandleRewardBasedVideoLeftApplication;

    }

    // Update is called once per frame
    void Update () {

    }

    // Returns an ad request with custom ad targeting.
    private AdRequest CreateAdRequest()
    {
    return new AdRequest.Builder().Build();
    }

    public void RequestRewardBasedVideo()
    {

    #if UNITY_EDITOR
    string adUnitId = "unused";
    #elif UNITY_ANDROID
    string adUnitId = Rewarded_ID;
    #elif UNITY_IPHONE
    string adUnitId = Rewarded_ID;
    #else
    string adUnitId = "unexpected_platform";
    #endif

    this.rewardBasedVideo.LoadAd(this.CreateAdRequest(), adUnitId);
    }

    public void ShowRewardBasedVideo()
    {
    if(rewardBasedVideo.IsLoaded())
    {
    rewardBasedVideo.Show();

    }
    else
    {
    Debug.Log("Rewarded Ad Load");
    }

    }

    #region RewardBasedVideo callback handlers

    public void HandleRewardBasedVideoLoaded(object sender, EventArgs args)
    {
    }

    public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args)
    {
    }

    public void HandleRewardBasedVideoOpened(object sender, EventArgs args)
    {
    }

    public void HandleRewardBasedVideoStarted(object sender, EventArgs args)
    {
    }

    public void HandleRewardBasedVideoClosed(object sender, EventArgs args)
    {
    RequestRewardBasedVideo();
    }

    public void HandleRewardBasedVideoRewarded(object sender, Reward args)
    {
    string type = args.Type;
    double amount = args.Amount;

    repanel.SetActive(true);
    }

    public void HandleRewardBasedVideoLeftApplication(object sender, EventArgs args)
    {
    MonoBehaviour.print("HandleRewardBasedVideoLeftApplication event received");
    }

    #endregion
    }

    < Bu ileti mobil sürüm kullanılarak atıldı >



  • class ı boş bir GameObject in içine atıp singleton yapmayı bir dene istersen. Böylece sahneler arasında bu GameObject yok olmaz. Ana sahneye geri döndüğünde 2. bir kopyasının oluşmadığına emin ol.

    Bilmeyenler için örnek singleton;

    public class SomeClass : MonoBehaviour {
    private static SomeClass _instance;

    public static SomeClass Instance { get { return _instance; } }


    private void Awake()
    {
    if (_instance != null && _instance != this)
    {
    Destroy(this.gameObject);
    } else {
    _instance = this;
    }
    }
    }



    < Bu mesaj bu kişi tarafından değiştirildi eeerdem -- 31 Mart 2019; 17:26:18 >
  • singleton igrenc bir pattern
  • 
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.