- Home /
 
               Question by 
               spacelyjoe · Sep 26, 2014 at 10:51 PM · 
                colorrectrectangle  
              
 
              Is there a way to color in a rect?
 Rect rec = new Rect (0, 0, Screen.width, Screen.height/4);
so I'd want something like rec.ColorFill(Orange)
anyone know a way to achieve something like this?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by robertbu · Sep 26, 2014 at 11:30 PM
In your favorite image editing program, create a white texture. It does not have to be very big. Then you can do:
 void OnGUI() {
     GUI.color = Color.red;
     GUI.DrawTexture(rec, tex);
 }
Where 'tex' is a reference to your texture. Note the rec is in GUI coordinates. If your rec is in Screen coordinates, you'll need to the following:
 rec.y = Screen.height - rec.y;
Your answer
 
 
             Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
Changing two different objects renderer colour 1 Answer
Unity UI Rect 0 Answers
Problems with Rect 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                