예제 #1
0
        private IEnumerator _ShowAd()
        {
            button.enabled = false;
            _error         = false;

            var now = DateTime.UtcNow;

            while (!_ad.IsReady && (DateTime.UtcNow - now).TotalSeconds < loadTimeout)
            {
                _loading = true;
                RefreshUi();
                _ad.CheckReload();
                yield return(new WaitForSeconds(0.5f));
            }

            _loading = false;
            _error   = !_ad.IsReady;
            RefreshUi();

            if (!_error)
            {
                _ad.ShowOnResult(_OnResult);
            }
            button.enabled = true;
        }
예제 #2
0
        private void Awake()
        {
            if (Button == null)
            {
                Button = GetComponent <Button>();
            }
            if (CanvasGroup == null)
            {
                CanvasGroup = GetComponent <CanvasGroup>();
            }

            _ad = StencilAds.GetAdByType(AdType);
            Button.onClick.AddListener(() =>
            {
                _ad.ShowOnResult(_OnResult);
            });
        }