using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Dialogs : MonoBehaviour {
public bool skipText;
public bool isPrint;
public static string textMess;
public GameObject Textdia;
// Use this for initialization
void Start () {
StartCoroutine (TextPrint(Textdia.GetComponent<Text>(), textMess, 0.1f, skipText));
//isPrint = false;
}
// Update is called once per frame
void Update () {
//Debug.Log(textMess);
}
public IEnumerator TextPrint(Text output, string input, float delay, bool skip)
{
if (isPrint) yield break;
isPrint = true;
for (int i=0; i < input.Length; i++)
{
if (skip) { output.text = input; break; }
output.text = input.Substring(0, i);
yield return new WaitForSeconds(delay);
}
//Debug.Log (output);
}
}
ошибка в юнити:
NullReferenceException: Object reference not set to an instance of an object
Dialogs+c__Iterator1.MoveNext () (at Assets/scripts/UI/Dialogs.cs:31)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
Dialogs:Start() (at Assets/scripts/UI/Dialogs.cs:16)