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 charlesvi · Sep 28, 2013 at 05:25 AM · lightingcolormaterial colorfree-versionrgb

Colors Seem all wrong when I set them in RGB

So I set a color = new Color(10,40,90); thinking I'm going to get a dark blue but I get a bright white.

Pretty much I seem limited to only the colors that can be found doing color.red or w/e

Whats going on here?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by robertbu · Sep 28, 2013 at 05:26 AM

Color in unity are expressed as floats in the range of 0.0 to 1.0. So your blue color would approximately be

 color = new Color(.04f, .16f, .35f);
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 charlesvi · Sep 28, 2013 at 05:39 AM 0
Share

Wow, okay. For some reason I assumed it would be the normal 0 - 255 well that explains it so I pretty much had it as 255 255 255. Is there a handy conversion chart? or is it just a % thing where every 50 is roughly a .2? And thanks.

avatar image robertbu · Sep 28, 2013 at 05:50 AM 2
Share

No conversion chart...just value/255. There is a Color32 in Unity which is 0-255. It can be implicitly converted to a Color. But most things you interact with will be of type Color not Color32.

avatar image mikek400 · Aug 15, 2016 at 01:21 PM 1
Share

@robertbu Thanks for your answer but still have to indicate the values are floating point or Unity spits out compile errors. i.e.

 color = new Color(.04, .16, .35);
 
 //becomes
 
 color = new Color(.04f, .16f, .35f);





avatar image
2

Answer by Bunny83 · Aug 15, 2016 at 02:08 PM

Alternatively you can now also use the "Color32" struct which represents an RGBA value that consists of 4 byte values in the range of 0 - 255. Color and Color32 have implicit casting operators so they are automatically converted into each other.

 // C#
 Color someColorVar;
 
 // somewhere else:
 someColorVar = new Color32(10, 40, 90, 255);

Here the Color32 is implicitly converted into a Color.

Unforunately "Color32" doesn't have an additional constructor that takes only 3 values as "Color" has. So you always have to explicitly specify the alpha value. However you can directly use byte values

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

17 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

Related Questions

Issues with changing light colour 2 Answers

Material color won't update! 2 Answers

Switch between random colors 4 Answers

Color index operator not working properly 1 Answer

Change Color in C# with RGB Values? 4 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