Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Ошибка на unity NullReferenceException: Object reference not set to an instance of an object

Caveira Siege Знаток (439), открыт 2 недели назад
помогите, пожалуйста

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LapTimeManager : MonoBehaviour {

public static int MinuteCount;
public static int SecondCount;
public static float MilliCount;
public static string MilliDisplay;

public GameObject MinuteBox;
public GameObject SecondBox;
public GameObject MilliBox;

void Update () {
MilliCount += Time.deltaTime * 10;
MilliDisplay = MilliCount.ToString ("F0");
MilliBox.GetComponent<Text>().text = "" + MilliDisplay;

if (MilliCount >= 10) {
MilliCount = 0;
SecondCount += 1;
}

if (SecondCount <= 9) {
SecondBox.GetComponent<Text> ().text = "0" + SecondCount + ".";
}

else {
SecondBox.GetComponent<Text> ().text = "" + SecondCount + ".";
}

if (SecondCount >= 60) {
SecondCount = 0;
MinuteCount += 1;
}

if (MinuteCount <= 9) {
MinuteBox.GetComponent<Text> ().text = "0" + MinuteCount + ":";
}

else {
MinuteBox.GetComponent<Text> ().text = "" + MinuteCount + ":";
}
}
}
1 ответ
Коля Колесников Ученик (211) 2 недели назад
А какой номер строки, где именно ошибка? Пока могу предложить, что не все обьекты на перемены накинул.
Caveira SiegeЗнаток (439) 2 недели назад
уже разобрался, спасибо.
Похожие вопросы