user interface - Make a gameobject appear after dialogue text finishes being typed out? -


so i'm creating dialogue system game , i'm trying achieve gameobject/image appear after text said npc. wanted achieve typewriter effect the dialogue text each character of text typed out during specific amount of frames/time in dialogue box. question want indicate sentence has ended showing "nextbutton" appear after sentence has been typed out. realize math , add button timed after x amount of frames/time each sentence seems convoluted , time consuming each piece of dialogue. wondering if there way show nextbutton after text finishes function. please , thank you!

 unityengine;  using system.collections;  using unityengine.ui;  public class timeautotext : monobehaviour {       // attach ui text component (with full text there)           text txt;          string story;          public gameobject nextbutton;          private gameobject t1;          public    gameobject t2;           void awake()           {                  nextbutton.setactive (false);              txt = getcomponent<text> ();              story = txt.text;              txt.text = "";              startcoroutine ("playtext");          }           ienumerator playtext()          {              foreach (char c in story)               {                  txt.text += c;                   yield return new waitforseconds (0.100f);                   nextbutton.setactive (true);                }          }       void start()      {          t2.setactive(false);      }      void update ()      {           t1 = this.gameobject;           if (input.getkey (keycode.return))           {                  nextbutton.setactive (false);              t1.setactive (false);              t2.setactive (true);           }        }       } 


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -