Страница 1 из 1

ошибка в скрипте Unity Ads

СообщениеДобавлено: 01 июл 2018, 15:26
kirya_355
короче взял пример скрипта с сайта unity ads , но вылезла ошибка
Assets/scripts/UnityAdsButton.cs(47,45): error CS0246: The type or namespace name `ShowResult' could not be found. Are you missing an assembly reference?

вот код
Синтаксис:
Используется csharp

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Advertisements;

[RequireComponent(typeof(Button))]
public class UnityAdsButton : MonoBehaviour
{
   
    Button m_Button;

    public string placementId = "rewardedVideo";
    public string action;

    void Start()
    {
        m_Button = GetComponent<Button>();
        if (m_Button) m_Button.onClick.AddListener(ShowRewardedAd);
if (PlayerPrefs.GetInt ("NoAds") != 1)
                 {
             if (Advertisement.isSupported)
                          {
        Advertisement.Initialize ("2578372", false);
              }
           else
        Debug.Log ("Platform is not supported");
                 }            
       
    }

    void Update()
    {
        if (m_Button) m_Button.interactable = Advertisement.IsReady(placementId);
    }

   

   
 public void ShowRewardedAd()
              {
                if (Advertisement.IsReady("rewardedVideo"))
                {
                  var options = new ShowOptions { resultCallback = HandleShowResult };
                  Advertisement.Show("rewardedVideo", options);
                }
              }

              private void HandleShowResult(ShowResult result)
              {
                switch (result)
                {
                  case ShowResult.Finished:
                    Debug.Log("The ad was successfully shown.");
                     switch (action)
                    {
                case "shop":
                   int i = PlayerPrefs.GetInt("allscore");
                    PlayerPrefs.SetInt("allscore",i+50);
           
                    break;
                    }
                    break;
                  case ShowResult.Skipped:
                    Debug.Log("The ad was skipped before reaching the end.");
                    break;
                  case ShowResult.Failed:
                    Debug.LogError("The ad failed to be shown.");
                    break;
                }
              }  
}

Re: ошибка в скрипте Unity Ads

СообщениеДобавлено: 01 июл 2018, 16:12
1max1