Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Dec 15, 2012 at 09:03 AM by burnpsy for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by burnpsy · Feb 21, 2012 at 04:58 AM · guitextbox

Making Text Boxes With Letters Appearing One At A Time

I've been trying to do something like this to tell the story in my game.

But I've been unable to figure out how to do it, mainly because I can't think of any ways to make one letter appear on the screen at a time, rather than a character's entire line.

So I must ask. How can I make text boxes that have letters appear one at a time instead of all at once? While I'm asking, links to any tutorials and such regarding things like that would be appreciated., since I'm fairly new to Unity.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

  • Sort: 
avatar image
4
Best Answer

Answer by Berenger · Feb 21, 2012 at 06:09 AM

The GUI stuff isn't really related here. How Fill a string one letter at a time ?

private var str: string; function Start(){ AnimateText("Pretty cool text"); }

function AnimateText(string strComplete){ var i: int = 0; str = ""; while( i < strComplete.Length ){ str += strComplete[i++]; yield WaitForSeconds(0.5); } }

and C# (need to be explicitely inside a class, but I guess you already know that)

private string str; void Start(){ StartCoroutine( AnimateText("Pretty cool text") ); }

IEnumerator AnimateText(string strComplete){ int i = 0; str = ""; while( i < strComplete.Length ){ str += strComplete[i++]; yield return new WaitForSeconds(0.5F); } }

Then the GUI part is obvious.

Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image burnpsy · Feb 21, 2012 at 07:20 AM 0
Share

Can I get that in C#? I keep getting a load of errors when trying to convert it myself.

avatar image Berenger · Feb 21, 2012 at 03:14 PM 1
Share

Facepalm is correct. You just need to call animateText with StartCoroutine() then. And animateText doesn't need to be public.

avatar image burnpsy · Feb 22, 2012 at 12:51 AM 0
Share

O$$anonymous$$ thanks. What I'm not getting now is how exactly I'm supposed to display that. I tried making another class and putting it in like so:

void OnGUI(){ GUI.Box(new Rect(10,400,1260,225), "placeholder"); }

With a whole slew of things in the slot where you see the placeholder... but not a single one of the many things I've tried actually shows this self-filling string ins$$anonymous$$d of just bringing up an error message.

avatar image Berenger · Feb 22, 2012 at 02:35 AM 1
Share

use the variable str ins$$anonymous$$d of "placeholder". If that's what you mean, I'm not sure.

avatar image burnpsy · Feb 22, 2012 at 03:12 AM 0
Share

That worked. Thank you.

avatar image
3

Answer by Facepalm · Feb 21, 2012 at 08:20 AM

 public class AnimatedText : MonoBehaviour {
    public AnimatedText(){}
 
    public void animateText(string strComplete){
       int i = 0;
       string str = "";
       while(i < strComplete.Length){
          str += strComplete[i++];
          new WaitForSeconds(0.5f);
       }
    }
 }
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Akeronz · Aug 23, 2013 at 05:23 AM 0
Share

Thank you @Berenger and @Facepalm! Just what I needed. Figuring out that you are supposed to clear the string before making characters appear can be very tricky!

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get a pop-up window floating next to a gameobject? 1 Answer

Providing a start location for GUILayout.beginHorizontal ? 0 Answers

How can I clear a textbox and repeat the text with my effect? 0 Answers

Simple text in a box - on player collision 2 Answers

How do you get a caret to show in GUILayout.TextField ??? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges