• Ошибка в скрипте, Unity ADS, как настроить?

    @gorgey Автор вопроса
    Все решил, спасибо всем.
    using UnityEngine;
    using UnityEngine.Advertisements;
    using System.Collections;
    
    public class GameState : Singleton<GameState> {
    
    	public bool startGame = false;
    	public bool endGame = false;
    	private Bird player;
    	public BackgroundGame[] background;
    
    	private CoinsManager coins;
    
    	private static int advCount = 0;
    
    	public GameObject uiEnd;
    	public GameObject uiStart;
    	public GameObject uiScore;
    	public GameObject uiHightCoins;
    	public bool deleteSave = false;
    
    	public AudioSource music;
    
    	void Start () {
    		if (PlayerPrefs.GetString ("NoAds") != "yes") {
    			if (Advertisement.isSupported) {
    				Advertisement.Initialize ("1667763", false);
    			}	else
    				Debug.Log ("Platform is not supported");
    			if (deleteSave)
    				PlayerPrefs.DeleteAll ();
    
    			player = FindObjectOfType<Bird> ();
    			coins = FindObjectOfType<CoinsManager> ();
    
    			uiEnd.SetActive(false);
    			uiStart.SetActive (true);
    			uiScore.SetActive (true);
    
    			startGame = false;
    			endGame = false;
    			advCount++;
    			music.Stop ();}
    	}
    
    	void Update () {
    		if(PlayerPrefs.GetString ("NoAds") != "yes") {
    			if (Advertisement.IsReady ()&& advCount %5 == 0)
    				Advertisement.Show();
    			for (int i = 0; i < background.Length; i++) {
    				if(!startGame)
    				{
    					background[i].enabled = false;
    				}else{
    					background[i].enabled = true;
    				}
    			}
    
    			if(player.isDead)
    			{
    				endGame = true;
    				startGame = false;
    				music.Stop();
    			}
    
    			if(endGame)
    			{
    				if(coins.Coin > coins.MaxCoins)
    				{
    					coins.MaxCoins = coins.Coin;
    					PlayerPrefs.SetInt("Coins", coins.MaxCoins);
    					coins.MaxCoins = PlayerPrefs.GetInt("Coins");
    					coins.UpdateHightCoins("<color=yellow>New </color>",coins.MaxCoins);
    				}
    
    				if(Input.GetMouseButtonDown(0))
    					Application.LoadLevel(Application.loadedLevel + 0);
    
    				uiEnd.SetActive(true);
    				uiScore.SetActive(false);
    
    			}
    
    			if(!endGame)
    
    			if (Input.GetMouseButtonDown (0) && !startGame)
    			{
    				startGame = true;
    				endGame = false;
    				music.Play();
    
    				uiStart.SetActive (false);
    			}
    		}
    
    	}
    
    }
    Ответ написан
    Комментировать