Hi!! First time posting here… I dont understand why this doesnt work. Is a typing script and when I hit on Play, this only show 1 letter and stops.
(Sorry for my english)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class TextoEfectos : MonoBehaviour
{
private TMP_Text _mTextMeshPro;
// Sets the reveal speed in seconds.
public float RevealSpeed = 0.01f;
// The current page of the text, needs to be changed when you display the next page.
public int CurrentPage = 0;
// Lets other scripts know when to allow the next page to load.
public bool IsWriting;
void Awake()
{
IsWriting = true;
_mTextMeshPro = GetComponent<TMP_Text>();
}
IEnumerator Start()
{
// Force and update of the mesh to get valid information.
_mTextMeshPro.ForceMeshUpdate();
var totalVisibleCharacters = _mTextMeshPro.textInfo.characterCount; // Get # of Visible Character in text object
var counter = 0;
var visibleCount = 0;
while (true)
{
visibleCount = counter % (totalVisibleCharacters + 1);
_mTextMeshPro.maxVisibleCharacters = visibleCount; // How many characters should TextMeshPro display?
if (_mTextMeshPro.textInfo.pageInfo[CurrentPage].lastCharacterIndex >= visibleCount)
{
IsWriting = true;
counter += 1;
}
else
{
IsWriting = false;
}
yield return new WaitForSeconds(0.01f);
}
}
}