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
1
Question by g0tNoodles · Dec 02, 2012 at 07:13 PM · colorslider

Change text colour in game using the colour spectrum.

Hello, I am trying to use sliders in order to change the colour of my text to help people with visual impairments customise the game. Is there a way to access the spectrum while in game to change the colour or is there a way to set r/g/b to three sliders to change the colour?

Thanks!

Comment
Add comment · Show 2
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 MD_Reptile · Dec 02, 2012 at 07:19 PM 0
Share

Surely you could have three values for R,g,b and then clamp between the max and $$anonymous$$, and create the slider with gui objects, measure the distance the slider is at and assign values from that.

Wouldn't be a spectrum, that would require some extra coding

avatar image DavidDebnar · Dec 02, 2012 at 08:46 PM 0
Share

You could just create a sectrum image, and then calculate the colors with the mouse pos.

3 Replies

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

Answer by Eric5h5 · Dec 02, 2012 at 07:19 PM

See here for an example of RGB sliders. For a spectrum, a simple way would be to make a texture with the spectrum and then use GetPixel to determine the color.

Comment
Add comment · Show 3 · 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 g0tNoodles · Dec 02, 2012 at 11:26 PM 0
Share

I used the RGB sliders and have them on screen and changing the colour within the editor but I cannot get them to change my text colour. I used GUI.color = myColour and also tried GUI.contentColor = myColour.

Where am I going wrong with it?

Thanks.

avatar image TheDarkVoid · Dec 03, 2012 at 12:28 AM 0
Share

you need to be applying the color to the GUIStyle

avatar image g0tNoodles · Dec 03, 2012 at 05:19 PM 0
Share

Thanks to everyone that posted something but these two bits of info from Eric and Dark worked for me.

Once again, thank you very much!

avatar image
1

Answer by TheDarkVoid · Dec 02, 2012 at 07:27 PM

Use this to do exactly that. You will need to modify the Rects to fit your case

 GUI.Label(new Rect(215, 15, 100, 20), "Color: ");
 Texture2D previewTex = new Texture2D(1, 1);
 previewTex.SetPixel(0,0, curColor);
 previewTex.SetPixel(1,1, curColor);
 previewTex.Apply();
 GUI.DrawTexture(new Rect(215, 40, 75, 75), previewTex, ScaleMode.ScaleToFit);
 GUI.Label(new Rect(295, 30, 270, 20), new GUIContent("R: ", "The red value, adds red to the color"));
 curColor.r  = GUI.HorizontalSlider(new Rect(315, 35, 200, 20), curColor.r, 0, 1);
 float.TryParse(GUI.TextField(new Rect(525, 30, 100, 20), curColor.r.ToString()), out curColor.r); 
 GUI.Label(new Rect(295, 55, 270, 20), new GUIContent("G: ", "The green value, adds green to the color"));
 curColor.g  = GUI.HorizontalSlider(new Rect(315, 60, 200, 20), curColor.g, 0, 1);
 float.TryParse(GUI.TextField(new Rect(525, 55, 100, 20), curColor.g.ToString()), out curColor.g); 
 GUI.Label(new Rect(295, 80, 270, 20), new GUIContent("B: ", "The blue value, adds blue to the color"));
 curColor.b  = GUI.HorizontalSlider(new Rect(315, 85, 200, 20), curColor.b, 0, 1);
 float.TryParse(GUI.TextField(new Rect(525, 80, 100, 20), curColor.b.ToString()), out curColor.b); 
 GUI.Label(new Rect(295, 105, 270, 20), new GUIContent("A: ", "The alpha value, controls transparency"));
 curColor.a  = GUI.HorizontalSlider(new Rect(315, 110, 200, 20), curColor.a, 0, 1);
 float.TryParse(GUI.TextField(new Rect(525, 105, 100, 20), curColor.a.ToString()), out curColor.a); 
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
-2

Answer by difd 9999 · Dec 02, 2012 at 07:17 PM

In js Color.red Color.Green Ect. Hope I could help ps. Accept answers for more karma and answers

Comment
Add comment · Show 1 · 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 Eric5h5 · Dec 02, 2012 at 07:19 PM 0
Share

That's not at all what the question is asking.

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

14 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

Related Questions

Change material color with a three slider 2 Answers

GUI slider controls sunlight color? 3 Answers

using rgb to change color c# 1 Answer

Set base color of a specific material 1 Answer

Horizontal Slider Normal-Background Change Color Independently 3 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