Question by 
               Manacraft05 · Jan 27, 2019 at 07:16 PM · 
                arraytextstringwaitforsecondssubtitle  
              
 
              Wait For second realtime | Don't work !
Trying to wait 1 sec before updating the Text to the next line.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class SubtitleRenderer : MonoBehaviour
 {
     public SubtitleHandler subtitleHandler; //scriptable object which contain an array of strings
     public Text renderer;
     int number;
     // Start is called before the first frame update
     void Start()
     {
         renderer.text = "";
         number = 0;
         gameObject.GetComponent<Collider>().enabled = true; //set the trigger
         Debug.Log(subtitleHandler.Text.Length);
     }
 
     // Update is called once per frame
     void OnTriggerEnter()
     {
         renderer.text = subtitleHandler.Text[number];
         for (int i = 0; i < subtitleHandler.Text.Length; i++)
         {                
             StartCoroutine(Example());    
         }          
     }
     IEnumerator Example()
     {            
         yield return new WaitForSecondsRealtime(1);
         renderer.text = subtitleHandler.Text[number];
         number = number + 1;
     }
 }
               Comment
              
 
               
              Answer by tormentoarmagedoom · Jan 27, 2019 at 10:43 PM
Good day.
What "Don't work" means? nothing happens? or what?
Use
  yield return new WaitForSeconds(1);
The game don't wait. It execute all of the code at once.
Did you tried with WaitForSeconds() ?
one simple tip, This 2 lanes are exactly the same:
      number = number + 1;
      number +=  1;
Bye!
Your answer
 
 
             Follow this Question
Related Questions
.Contains(array) 1 Answer
Cannot use operand '<' on type string and string 0 Answers
BCE0022: Cannot convert 'String' to 'int' 0 Answers
Printing a string of text to a Texture2D 1 Answer
Array cannot read Greek characters 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                