[英]Scoring system collect item not updating Text UI - Unity C#
我創建了 2 個腳本,一個處理項目的集合,另一個處理顯示在屏幕上的分數。 目前,聲音播放並且項目在觸發輸入時被銷毀,但分數的 UI-Text 不會更新。 我試圖在 ScoringSystem 和 CollectGem 中添加分數,這兩個腳本都在下面。
ScoringSystem 附加到一個游戲對象,TextScore 分配給插槽。
有人能明白為什么文本不會在集合上加 1 嗎?
收藏寶石
public class CollectGem : MonoBehaviour
{
public AudioSource collectNoise;
public void OnTriggerEnter(Collider collider)
{
collectNoise.Play();
ScoringSystem.theScore += 1;
Destroy(gameObject);
}
}
評分系統
public class ScoringSystem : MonoBehaviour
{
public GameObject score;
public static int theScore;
void update()
{
score.GetComponent<Text>().text = "Gems: " + theScore;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.