Question by
Danicted · Sep 22, 2015 at 06:52 PM ·
c#2d-platformer
Changing Color
Hey! I am quite new to scripting and programming in general, and I am trying to change a text to a specific color when highlighted with the cursor. I have managed to do this correctly using
public void OnMouseEnter(){
PlayText.color = Color.red;}
but this only works with main color like red, black, yellow, blue etc. What do I do if I want the same thing with a custom color code?
Comment
Best Answer
Answer by Xephex · Sep 22, 2015 at 07:24 PM
PlayText.color = Color(255,0,0,255) // creates fully opaque red text.
PlayText.color = Color(0,255,0,125) // this creates semi-transparent green text
This is in the format:
Color(Red ,Green ,Blue ,Alpha(transparency))
All channels are on scale of 0 - 255. Hope this helps :)
Your answer
Follow this Question
Related Questions
Scrolling background wall collision problem 0 Answers
Inconsistent Jump Heights 1 Answer
One 2D Raycast Not Stopping Even Though Others Do? 0 Answers
Enemy Spawning Help (2D Platformer, C#) 2 Answers