- Home /
Find out RGB in Viewport
Hi I want to store the color I assigned to an object in the inspector. Let's say I set my material to a color I am happy with and want to store it in my script so I can switch back to it later. Atm I use a print screen, go to Photoshop and use the color picker to find out the RGB, because Unity is displaying them in HSV. That can't be right, suggestions?
Answer by robertbu · Oct 10, 2014 at 03:37 PM
Unity uses RGB, not HSL. Unity's color values stored in the Material go from 0.0 to 1.0, not 0 to 255 like in Photoshop. Unity does have a Color32 you can cast the Color class to in order to output colors in the format used by Photoshop:
var c32 : Color32 = renderer.material.color;
Debug.Log(c32);
Thank you for the quick reply, but I did not mean Unity internally, I ment the color picker. If you want to change the color of a material in the inspector, a color picker appears, where you can choose a color, either from clicking on it or manipulating HSV, I want to find out the RGB value of that color. Preferably without scripting, it's just 3 Numbers.
In the color picker, on the right hand side, opposite the 'Sliders' heading, there is a icon. Click on the icon, and the representation of the sliders change from HSL to RGB.
I must have clicked all of them except that one, thanks!