Beispiel #1
0
        //public float reShowTime = 30;
        //public bool useReShow;
        //float add;
        //bool isRun;
        public void Awake()
        {
            //Debug.Log($"w::{Screen.width},h::{Screen.height},sx::{size.x},sy::{size.y} rx::{size.x * Screen.width},ry::{size.y * Screen.height}" );
            expressAdInteractionListener = new ExpressAdInteractionListener(1, this);
            dislikeCallback = new ExpressAdDislikeCallback(this, 1);
            onClose        += (v) =>
            {
                //StartCountDown();
                LoadExpressBannerAd();
            };
            listener = new ExpressAdListener(this, 1);
#if !UNITY_EDITOR
            retryer.Regist(this);
#endif
        }
    /// <summary>
    /// Show the Banner Ad.
    /// </summary>
    public void ShowBannerAd()
    {
#if UNITY_IOS
        if (this.iExpressBannerAd == null)
        {
            Debug.LogError("请先加载广告");
            this.information.text = "请先加载广告";
            return;
        }

        this.inputX = GameObject.Find("Canvas/InputFieldX").GetComponent<InputField>();
        this.inputY = GameObject.Find("Canvas/InputFieldY").GetComponent<InputField>();

        int x;
        int y;
        int.TryParse(this.inputX.text, out x);
        int.TryParse(this.inputY.text, out y);
        Debug.Log("ShowExpressAd x坐标---" + x);
        Debug.Log("ShowExpressAd y坐标---" + y);

        Debug.Log("ShowExpressAd WindowSafeAreaInsetsTop---" + PangleTools.getWindowSafeAreaInsetsTop());
        Debug.Log("ShowExpressAd WindowSafeAreaInsetsLeft---" + PangleTools.getWindowSafeAreaInsetsLeft());
        Debug.Log("ShowExpressAd WindowSafeAreaInsetsBottom---" + PangleTools.getWindowSafeAreaInsetsBottom());
        Debug.Log("ShowExpressAd WindowSafeAreaInsetsRight---" + PangleTools.getWindowSafeAreaInsetsRight());
        Debug.Log("ShowExpressAd ScreenWidth---" + PangleTools.getScreenWidth());
        Debug.Log("ShowExpressAd ScreenHeight---" + PangleTools.getScreenHeight());

        if (y < 20)
        {
            y = (int)PangleTools.getScreenHeight() - 750 - (int)PangleTools.getWindowSafeAreaInsetsBottom();
        }

        this.iExpressBannerAd.ShowExpressAd(x, y);
#else
        if (this.mExpressBannerAd == null)
        {
            Debug.LogError("请先加载广告");
            this.information.text = "请先加载广告";
            return;
        }
        //设置轮播间隔 30s--120s;不设置则不开启轮播
        this.mExpressBannerAd.SetSlideIntervalTime(30 * 1000);
        ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this, 1);
        ExpressAdDislikeCallback dislikeCallback = new ExpressAdDislikeCallback(this, 1);
        NativeAdManager.Instance().ShowExpressBannerAd(GetActivity(), mExpressBannerAd.handle, expressAdInteractionListener, dislikeCallback);
#endif
    }
    /// <summary>
    /// Show the reward Ad.
    /// </summary>
    public void ShowExpressInterstitialAd()
    {
#if UNITY_IOS
        if (this.iExpressInterstitialAd == null)
        {
            Debug.LogError("请先加载广告");
            this.information.text = "请先加载广告";
            return;
        }
        this.iExpressInterstitialAd.ShowExpressAd(0, 0);
#else
        if (this.mExpressInterstitialAd == null)
        {
            Debug.LogError("请先加载广告");
            this.information.text = "请先加载广告";
            return;
        }
        ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this, 1);
        NativeAdManager.Instance().ShowExpressInterstitialAd(GetActivity(), mExpressInterstitialAd.handle, expressAdInteractionListener);
#endif
    }
    /// <summary>
    /// Show the expressFeed Ad.
    /// </summary>
    public void ShowExpressFeedAd()
    {
#if UNITY_IOS
        if (this.mExpressFeedad == null)
        {
            Debug.LogError("请先加载广告");
            this.information.text = "请先加载广告";
            return;
        }
        this.mExpressFeedad.ShowExpressAd(5,100);
#else
        if (this.mExpressFeedad == null)
        {
            Debug.LogError("请先加载广告");
            this.information.text = "请先加载广告";
            return;
        }
        ExpressAdInteractionListener expressAdInteractionListener = new ExpressAdInteractionListener(this, 0);
        ExpressAdDislikeCallback dislikeCallback = new ExpressAdDislikeCallback(this,0);
        this.mExpressFeedad.SetExpressInteractionListener(
            expressAdInteractionListener);
        NativeAdManager.Instance().ShowExpressFeedAd(GetActivity(),mExpressFeedad.handle,expressAdInteractionListener,dislikeCallback);
#endif
    }