Answer the question
In order to leave comments, you need to log in
Analyzed from and to. What's wrong?
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);
}
}
Answer the question
In order to leave comments, you need to log in
for (int i=0; i < input.Length - 1; i++)
And you generally public IEnumerator TextPrint
return nonsense. IEnumerator
Your textMess is equal to nothing .. you see.
not an empty string ... but straight ANYTHING.
and Nothing has a Length .
initialize the string at least ))
and in general, debugging works fine in the unit.
and nothing prevents Debug.Log Add and see what you send to the parameters
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question