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 /
avatar image
0
Question by hardmode2236 · Feb 06, 2015 at 08:23 AM · uitextstringhtml

rich text issue

i'm working with a UI.text element and i have the rich text checked, but i'm using a little function that types out strings character by character with a little pause inbetween. I wanted to color code the NPCs dialogue in my game and when i have it write out something like:

 "<color=#75A3FF>blah blah blah</color>"

it writes the text out, but the string i'm writing the characters to wont understand the HTML color code until the very end when i reach the ending color brackets, then once its all typed out, it recognizes the color coding and it corrects itself. but until then i can see the function typing everything out. does anyone know a way around this?

maybe i could input the entire color code first, then type the characters into the middle of it? but i don't know how i would go about that. maybe using substrings?

  • ill be trying to do this with substrings unless someone else and give me a better route

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by majecty · Nov 18, 2018 at 01:43 AM

I created a simple library for this issue.

With the library you can get substring of rich text using simple function.

 var richText = "<color=blue>blue</color>black";
 richText.RichTextSubString(3); // <color=blue>blu</color>
 richText.RichTextSubString(6); // <color=blue>blue</color>bl

You can download it in the below link.

https://github.com/majecty/Unity3dRichTextHelper

Comment
Add comment · 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
0

Answer by Johnz1234 · Feb 06, 2015 at 10:04 AM

https://www.youtube.com/watch?v=w33cOjMT0fE here is a tutoril :D

Comment
Add comment · 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
0

Answer by hardmode2236 · Feb 06, 2015 at 09:42 AM

Ok as it turns out this wasn't as bad as i thought it was going to be. i just use this code:

 textBox.text +=code;
 while(count<s.Length)
     {
         //cut the code in between code brackets
         textBox.text = textBox.text.Substring(0, textBox.text.Length-8);
         //put in the letter and the ending bracket
         textBox.text += s[c]+"</color>";
         count++;
         yield WaitForSeconds(.02);
     }

this works, but i'm wondering if there's a more elegant solution. otherwise this just has to keep cutting and adding that ending HTML code to the end of the string every letter.

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Text UI is not being assigned 2 Answers

Multiple Rich Text Not Working 1 Answer

Selecting a part of string in input field 1 Answer

Remove the & at the end of concatenated string 0 Answers

Ui text to string ? 1 Answer


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