Ошибка Object reference not set to an instance of an object - Форум Игроделов
Чт, 02 Май 2024, 15:31 
 
Приветствую Вас Гость Главная | Регистрация | Вход
Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Форум Игроделов » UNITY3D » СКРИПТИНГ » Ошибка Object reference not set to an instance of an object
Ошибка Object reference not set to an instance of an object
AlexCreateДата: Вс, 20 Сен 2015, 00:06 | Сообщение # 1
Нет аватара
 
Сообщений: 14
Награды: 0
Репутация: 0
Статус: Offline
Нашел на просторах интернета скрипт который считывает счет и все работает, но не высвечивается сам счет и высвечивается ошибка "Object reference not set to an instance of an object".
P.S помогите мне ещё настроить местоположение String ( Счетчика )
Код
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ScoreSystem : MonoBehaviour
{
         public GameObject Shar;
     public float score;
     private Transform target;
     public Text txt;

     void Start()
     {
         target = GameObject.Find("Shar").transform;
     }
     void Update()
     {

         EnterScore();
     }

     void EnterScore()
     {

         if (target.position.y < score)
         {
             score = target.position.y;
         }
         txt.text = score.ToString();

         if (txt.text.IndexOf('.') != -1)
             txt.text = txt.text.Remove(txt.text.IndexOf('.'));

     }
}
 
СообщениеНашел на просторах интернета скрипт который считывает счет и все работает, но не высвечивается сам счет и высвечивается ошибка "Object reference not set to an instance of an object".
P.S помогите мне ещё настроить местоположение String ( Счетчика )
Код
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ScoreSystem : MonoBehaviour
{
         public GameObject Shar;
     public float score;
     private Transform target;
     public Text txt;

     void Start()
     {
         target = GameObject.Find("Shar").transform;
     }
     void Update()
     {

         EnterScore();
     }

     void EnterScore()
     {

         if (target.position.y < score)
         {
             score = target.position.y;
         }
         txt.text = score.ToString();

         if (txt.text.IndexOf('.') != -1)
             txt.text = txt.text.Remove(txt.text.IndexOf('.'));

     }
}

Автор - AlexCreate
Дата добавления - 20 Сен 2015 в 00:06
Форум Игроделов » UNITY3D » СКРИПТИНГ » Ошибка Object reference not set to an instance of an object
  • Страница 1 из 1
  • 1
Поиск:
Загрузка...

Game Creating CommUnity © 2009 - 2024