我是 unity 的新手;我只是想在代碼源上測試一些東西,所以我聘請了一個自由職業(yè)者來實現(xiàn)廣告 廣告在玩家輸了 3 次后顯示,在暫停菜單中,我想每次玩家輸了都顯示,你能告訴我怎么做嗎?做到這一點并且要具體,因為我是這一切的新手這是我的廣告控件我真的很感激你的幫助最好的畢業(yè)生using UnityEngine;using System.Collections;using UnityEngine.UI;public class UIManager : MonoBehaviour{ public GameObject maskPanel, pausePanel, retrievePanel, gameOverPanel, levelClearPanel; public Text timerText, coinValueText; public float timeMax; private float currentTimer; public GameObject[] heart; public int coinToRetrieve; public Sprite[] starSpr; public Image starImg; public Text coinResultValue; void Awake () { GameManager._UIManager = this; } // Use this for initialization void Start () { currentTimer = timeMax; coinValueText.text = GameManager._gotCoin.ToString (); AudioManager.Instance.mainMusic.mute = false; } // Update is called once per frame void Update () { if (Mathf.CeilToInt (currentTimer) > 0) { currentTimer -= Time.deltaTime; timerText.text = Mathf.CeilToInt (currentTimer).ToString (); } if (Mathf.CeilToInt (currentTimer) == 0) { if (!GameManager.isGameOver) { AudioManager.Instance.PlayOutOfTime (); GameManager.isGameOver = true; StartCoroutine (GameOver ()); } } coinValueText.text = GameManager._gotCoin.ToString (); } public void Pause () { AdsControl.Instance.showAds (); Time.timeScale = 0.0f; maskPanel.SetActive (true); pausePanel.SetActive (true); } public void Resume () { Time.timeScale = 1.0f; maskPanel.SetActive (false); pausePanel.SetActive (false); }
2 回答

狐的傳說
TA貢獻1804條經(jīng)驗 獲得超3個贊
看起來在玩家失去三顆心后會顯示廣告。在上面的腳本中,玩家收到的心數(shù)當前由 GameManager 腳本設(shè)置。您可以通過更改來確認這一點...
SetHeart (GameManager._heart);
...在上面的腳本中:
SetHeart (1);
我假設(shè) GameManager 腳本將紅心數(shù)設(shè)置為 3。這只是一個臨時解決方案,用于測試您的廣告是否會在僅輸?shù)粢淮斡螒蚝箫@示。
您可以更新問題以包含 GameManager 腳本嗎?您應(yīng)該能夠通過在您的項目中搜索public class GameManager
靠近腳本頂部的腳本來找到該腳本。

臨摹微笑
TA貢獻1982條經(jīng)驗 獲得超2個贊
我不知道您是否仍在尋找答案,但首先您也使用 AdsControl 單例在暫停時展示廣告。(如果這是您想要的,但您沒有在問題中提到它,請使用它)。
AdsControl.Instance.showAds();
如果您沒有任何隱藏代碼讓協(xié)程在每次游戲結(jié)束時運行,那么您已經(jīng)在每場比賽結(jié)束時都這樣做
- 2 回答
- 0 關(guān)注
- 169 瀏覽
添加回答
舉報
0/150
提交
取消