Пример #1
0
 private void Awake()
 {
     this.Bind();
     button = button ?? GetComponent <Button>();
     _ad    = StencilAds.GetAdByType(adType);
     button.onClick.AddListener(() => StartCoroutine(_ShowAd()));
 }
        public ActionResult Create(CreateVideoAdVm vm)
        {
            ViewBag.Title = "Create video ad";
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var videoAd = new VideoAd();

            videoAd.Path =

                var guid = Guid.NewGuid();
            var serverPath = Server.MapPath("~/adssample");
            var filePath   = string.Format("{0}\\{1}", serverPath, "ads2.xml");

            var vastCreationResult = vm.CreateVast(filePath);

            if (vastCreationResult.VastCreationResultType == VastCreationResultType.Failure)
            {
                ModelState.AddModelError(nameof(vm.VastVersion), vastCreationResult.Message);
                return(View());
            }

            // aadd

            return(RedirectToAction("Index"));
        }
Пример #3
0
 private void initUnityAds()
 {
     if (!AdConfig.getInstance().isEnableunityAd())
     {
         return;
     }
     unityAds = gameObject.AddComponent <UnityAds>();
 }
Пример #4
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        /// <param name="campaignId">The campaign ID.</param>
        /// <param name="videoId">The Youtube video ID.</param>
        public void Run(AdWordsUser user, long campaignId, string videoId)
        {
            // Get the VideoAdService.
            VideoAdService videoAdService = (VideoAdService)user.GetService(
                AdWordsService.v201406.VideoAdService);

            VideoAd videoAd = new VideoAd();

            videoAd.campaignId = campaignId;
            videoAd.name       = "My first video ad";
            videoAd.status     = VideoAdStatus.PAUSED;

            videoAd.headline       = "Best headline ever";
            videoAd.destinationUrl = "http://www.example.com";
            videoAd.displayUrl     = "www.example.com";
            videoAd.description1   = "My favorite line 1";
            videoAd.description2   = "My favorite line 2";

            videoAd.videoId = videoId;

            VideoAdDisplayFormat_VideoAdStatusMapEntry statusByFormat =
                new VideoAdDisplayFormat_VideoAdStatusMapEntry();

            statusByFormat.key   = VideoAdDisplayFormat.TRUE_VIEW_IN_STREAM;
            statusByFormat.value = VideoAdStatus.ENABLED;

            videoAd.statusByFormat = new VideoAdDisplayFormat_VideoAdStatusMapEntry[] {
                statusByFormat
            };

            try {
                VideoAdOperation operation = new VideoAdOperation();
                operation.operand   = videoAd;
                operation.@operator = Operator.ADD;

                VideoAdReturnValue retval = videoAdService.mutate(new VideoAdOperation[] { operation });
                if (retval != null && retval.value != null && retval.value.Length > 0)
                {
                    VideoAd newVideoAd = retval.value[0];
                    Console.WriteLine("Ad with id = {0} was added to campaign id {1}.", newVideoAd.id,
                                      newVideoAd.campaignId);
                }
                else
                {
                    Console.WriteLine("No video ads were added.");
                }
            } catch (Exception ex) {
                throw new System.ApplicationException("Failed to add video ad.", ex);
            }
        }
Пример #5
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);
            });
        }
Пример #6
0
        private IEnumerator Init()
        {
            for (;;)
            {
                switch (Type)
                {
                case AdType.Interstitial:
                    _ad = StencilAds.Interstitial;
                    break;

                case AdType.Rewarded:
                    _ad = StencilAds.Rewarded;
                    break;
                }
                if (_ad != null)
                {
                    break;
                }
                yield return(null);
            }
            _ad.OnState += OnState;
        }
Пример #7
0
 private void ResetAd(VideoAd ad)
 {
     ad.EmergencyReset();
 }