• 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
1
Question by UncoolName · Jul 18, 2016 at 09:07 AM · textcolortextfield

Changing text color while writing it one character at a time in a text field.

Hi!

I'm developing a game with a text box based dialogue system, like old jrpgs. I read the dialogue text from file and I write it one character at a time in a text field. If the player clicks a button, the entire line appears instantly.

I'm now trying to give more visual options to the text. I want to color only some words of a sentence. If I change the text field color it obviously works, but it applies the color to the whole field. If I use tags, it works when the whole sentence is written but it doesn't work while the text is showing one chararacter at a time.

I thought I could "read" the tag one character at a time while I'm displaying the text, ignore its characters and apply the color to what comes after it, but I don't know how I could apply the color to that.

How can I refer to some specific part of a text field so that I don't apply the color to the whole field?

This will also help me changing only some words text size.

Thank you in advance!

Luca.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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

I created a library for this situation.

https://github.com/majecty/Unity3dRichTextHelper

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

You can use the tag and display the text one character at a time correctly.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

62 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 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 avatar image avatar image

Related Questions

TextField does not update in Game 1 Answer

UI text wont highlight 0 Answers

How do I change UI button background AND button text on click(pressed)? 0 Answers

How can i change the color of all my texts and backgrounds? 1 Answer

Text Boxes Not Visible 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges