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 darkhog · Oct 06, 2013 at 06:50 PM · guirichtextbox

Richtext doesn't work

For some reason, RichText in GUI doesn't work for me. Nothing -colors, other things, even as basic thing as bold face doesn't work. I have following code:

 Rect descriptionRect = new Rect(invrect.x+((invrect.width/4)*4),invrect.y,invrect.width/3,invrect.height);
             GUIStyle boxstyle = GUI.skin.box;
             boxstyle.wordWrap=true;
             boxstyle.alignment = TextAnchor.MiddleLeft;
             boxstyle.richText=true;
             GUI.Box(descriptionRect,"<color:a40000>Name:</color> "+Globals.playerInventory.getItemName(Globals.SelectedItemID)+"\n"+"<color:c69500>Amount:</color> "+Globals.playerInventory.getItemAmount(Globals.SelectedItemID).ToString()+"\n"+"<color:00a400>Description:</color> "+Globals.playerInventory.getItemDescription(Globals.SelectedItemID),boxstyle);

Should work, right? Nope - even since I specifically set richText to true, text still turns out as:

<color:a40000>Name:</color> placeholder name <color:c69500>Amount:</color> 1223 <color:00a400>Description:</color> placeholder description

Not even tags are removed which would mean that something is going on behind the scenes. This is same even for most basic tags such as <b> or <i>.

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
1
Best Answer

Answer by TrickyHandz · Oct 06, 2013 at 06:59 PM

EDIT: Intially, I thought this was because of a null font setting, but I have since tested with and without a font being assigned. If the font is not assigned, it does use the default Arial font despite returning a null value for the font.

The real problem exists in the syntax of your color tags which I overlooked earlier. Your tags should be declared like this in your string:

 string colorName = "<color=#a40000>Name:</color>";

Apparently the use of a colon is disallowed for tagging in this case. Additionally, I dug up this nice reference on RichText from the manual that has predefined color tags you can use like this:

 string testColor ="<color=red>Name:</color>";


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 darkhog · Oct 06, 2013 at 07:12 PM 0
Share

Yeah, but for this particular script Inspector is already cluttered and I don't want to clutter it anymore.

Also I'm doing

 GUIStyle boxstyle = GUI.skin.box

Isn't that enough?

//edit: tried adding your code and it doesn't do the trick.

avatar image TrickyHandz · Oct 06, 2013 at 07:18 PM 0
Share

I have been able to pull this off without declaring a font and edited the answer above to reflect my new findings.

avatar image darkhog · Oct 06, 2013 at 08:24 PM 0
Share

Thanks! Now it works. I guess serves me right for playing Blockland - in modding for this game, tag for color was with colon ins$$anonymous$$d of equal sign.

avatar image TrickyHandz · Oct 06, 2013 at 08:27 PM 0
Share

@darkhog, you have made me dig up stuff about the GUI system I haven't used in a long time. It's rather fun for me. Since it works, mark the answer as accepted when you have a chance. Happy Coding!

avatar image darkhog · Oct 06, 2013 at 09:58 PM 0
Share

...done and thanks!

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

16 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

Related Questions

4.6 GUI Button inside a scrolling Text Box 0 Answers

c# - void method from external class. 2 Answers

drawing a box with GUI 3 Answers

Why is my GUI pushed over to the right? 0 Answers

How completly remove GUI.Repaint() calls ? 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