• 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 /
  • Help Room /
avatar image
0
Question by C4TFLY · Sep 23, 2015 at 06:38 PM · game development

Zelda-like conversations

Hello! I am currently in the process of making a game and I am thinking of a way to do conversations that appear, letter by letter (kind of like in Zelda or similar games). I do not have the money to buy an asset from the store, so I wonder if anyone knows how to make a conversation like this?

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

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by etopsirhc · Sep 23, 2015 at 10:17 PM

not tested, but this is more or less what you are looking for.

 string fullText = "your zelda like text here";
 string displayText = "";
 float typeDelay = 0.3f; // just an estimate
 int nextCharacter = 1;

 Update(){
     if (nextCharacter <= fullText.length){
         displayText = fullText.subString(0,nextCharacter);
         YourTextBox.text = displayText;
         nextCharacter++;
     }
 }
Comment
Add comment · Show 6 · 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 C4TFLY · Sep 26, 2015 at 07:56 AM 0
Share

There seems to be a lot of parts missing to this, was this meant for a script with texts that are done? Also, where does typeDelay come in? I think this is well on the way to working though.

avatar image etopsirhc C4TFLY · Sep 27, 2015 at 01:36 AM 0
Share

yeah, >< guess i shouldn't answer questions at 4am too tired to remember to make things work. the "YourTextBox" would be a variable linked externally to the GUI textbox meant to display the text. this it meant to be a bare bones setup, enough for the concept to work, but would need some things changed to actually incorporate it in a useful way.

      string fullText = "your zelda like text here";
      string displayText = "";
      float typeDelay = 0.3f; // just an estimate
      float lastCharacterTime= 0f;
      int nextCharacter = 1;
      Update(){
          if (nextCharacter <= fullText.length){
              if (typeDelay <= lastCharacterTime){
                  displayText = fullText.subString(0,nextCharacter);
                  YourTextBox.text = displayText;
                  nextCharacter++;
                  lastCharacterTime = 0;
              }else{
                  lastCharacterTime += Time.deltaTime;
              }
          }
      }
avatar image C4TFLY etopsirhc · Sep 28, 2015 at 05:28 PM 0
Share

Right, I think we're nearly there, the YourTextBox.text section doesn't like the .text part, and I end up adding a static string (or something like that) to make it happy, I am a bit rusty with Unity, so forgive me for my lack of knowledge, I really appreciate your help.

Show more comments
avatar image C4TFLY · Sep 29, 2015 at 02:47 PM 0
Share

Side note: Although @etopsirhc had the original code, @bubzy was the one who solved it in the end! $$anonymous$$udos to both of you though!

avatar image
0

Answer by C4TFLY · Sep 28, 2015 at 06:58 PM

Once again, I feel very stupid and I feel like I am missing something completely obvious, but here goes;

I have included a screenshot of the hierarchy and the text inspector, I will also include the slightly edited code, nothing that should matter.

alt text

alt text


f8cbd594b0566b845e7a2488a2d805cc.png (77.0 kB)
ee03903d59eb1a23c50a49c1c610d517.png (21.4 kB)
Comment
Add comment · Show 2 · 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 etopsirhc · Sep 29, 2015 at 03:30 AM 0
Share

wich ever object in the scene has the script attached to it, you need to select that, then drag the text box into the open slot labeled TestText.

avatar image C4TFLY etopsirhc · Sep 29, 2015 at 02:45 PM 0
Share

YES! After a proper read of the errors and doing what you told me, it finally worked!

https://gyazo.com/02430074ab2a96d86143dd42b108cdea

I really appreciate all your help! I am forever in your favor!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

30 People are following this question.

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

Related Questions

Is it possible to make a color wheel in a script? 0 Answers

Gambling Licence for Real Money games 0 Answers

Unable to publish WebGL project 0 Answers

help me please. NullReferenceException: Object reference not set to an instance of an object 0 Answers

Where to get "Swords and Shovels" videos to play! I have bought the subscription but don't get to know where to play the videos from? 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