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
2
Question by SoundGuy32 · May 26, 2010 at 07:20 PM · guiguilayoutguistylegui.button

button with content in multiple colors

hey,

i want to have a button (and labels) that have multiple colors. i suppose there's no way to format the string that i pass as a parameter to the button command

GUI.Button(GetBuysellButtonArea(), "Buy XXX gold for YYY money)"); where the string is in white and XXX is in RED and YYY is in BLUE ?

any suggestions? my idea is to create an empty button with several labels, each using a different style on top of the button. but i seems like a bad idea. esepcially since i'm considering i want the text to be centered in th button area, and i have no idea how to do that by combining labels, even if i ue GUILayout.

Oded

Comment
Add comment · Show 1
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 SoundGuy32 · May 26, 2010 at 08:50 PM 0
Share

i'm thinking i woudl like something like HT$$anonymous$$L where you can write

echo "buy XXX gold for YYY money";

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by qJake · Jun 08, 2010 at 10:29 PM

You cannot, as far as I know, color different words in a single label with different colors, and I honestly can't think of a way to do it, short of basically writing your own Label function (which would be a major pain). Have you considered using textures instead of labels? You can make a texture of the words you want to use (in one color, of the words that will always be the same), and then you can position the GUI.Labels in a different color with the number values that you want to fill in.

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 SoundGuy32 · Jun 15, 2010 at 11:54 PM 0
Share

i decided to give this idea up :( i need string concatenation of dynamic variables, with different length (i.e. 1 gold vs 100000 gold) and i want it to be nice and centered. i tried some methods nothing worked good.

avatar image qJake · Jun 16, 2010 at 01:12 AM 0
Share

While it is technically possible to do what you want to do, it would be a pain in the ass to code it so it looked nice. Sorry you had to give up, nonetheless.

avatar image
0

Answer by Berenger · Dec 06, 2010 at 02:34 PM

Any news about that ? I'm having the same problem, and I'd very like to find a solution ! There could be a hint here, but it's seems quite complicated, plus it doesn't compile on my unity :/

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 ytniu · Oct 27, 2011 at 12:49 PM

I think you can use FancyLabel - Multicolor and Multifont label. I didn't try with labels, but it should work.

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

1 Person is following this question.

avatar image

Related Questions

create a box that player can type in it 1 Answer

Open gui if player clicks on button 2 Answers

Can you use GUIStyle with GUILayout? 0 Answers

How to apply multiple styles to the same line(s) of GUI text 1 Answer

Styling an individual button in SelectionGrid 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