Skip to main content
Fixing typos.
Source Link
lvictorino
  • 2.6k
  • 1
  • 15
  • 23

Rect is not a Drawable thing so you cantcan't assign color to it. The Rect does not contain information for color, Unity Docs ref.

This is something you're going to change when you are drawing that Rect. Let suppose you want to draw button out of it then you do something like thinsthis:

drawArea = new Rect(0, 0, Screen.width, Screen.height);

 //Changing Button Color to Red.
 GUI.backgroundColor = Color.red;
 GUI.Button( rect, "red button", guiStyle );
 
//Changing Button Color to Blue.
 GUI.backgroundColor = Color.blue;
 GUI.Button( rect, "blue button", guiStyle );

The code is taken from Unity Answers.

I hope thins will helpthis helps.

Rect is not a Drawable thing so you cant assign color to it. The Rect does not contain information for color, Unity Docs ref.

This is something you're going to change when you are drawing that Rect. Let suppose you want to draw button out of it then you do something like thins:

drawArea = new Rect(0, 0, Screen.width, Screen.height);

 //Changing Button Color to Red.
 GUI.backgroundColor = Color.red;
 GUI.Button( rect, "red button", guiStyle );
 
//Changing Button Color to Blue.
 GUI.backgroundColor = Color.blue;
 GUI.Button( rect, "blue button", guiStyle );

The code is taken from Unity Answers.

I hope thins will help.

Rect is not a Drawable thing so you can't assign color to it. The Rect does not contain information for color, Unity Docs ref.

This is something you're going to change when you are drawing that Rect. Let suppose you want to draw button out of it then you do something like this:

drawArea = new Rect(0, 0, Screen.width, Screen.height);

 //Changing Button Color to Red.
 GUI.backgroundColor = Color.red;
 GUI.Button( rect, "red button", guiStyle );
 
//Changing Button Color to Blue.
 GUI.backgroundColor = Color.blue;
 GUI.Button( rect, "blue button", guiStyle );

The code is taken from Unity Answers.

I hope this helps.

Source Link
Swati
  • 1.2k
  • 1
  • 11
  • 19

Rect is not a Drawable thing so you cant assign color to it. The Rect does not contain information for color, Unity Docs ref.

This is something you're going to change when you are drawing that Rect. Let suppose you want to draw button out of it then you do something like thins:

drawArea = new Rect(0, 0, Screen.width, Screen.height);

 //Changing Button Color to Red.
 GUI.backgroundColor = Color.red;
 GUI.Button( rect, "red button", guiStyle );
 
//Changing Button Color to Blue.
 GUI.backgroundColor = Color.blue;
 GUI.Button( rect, "blue button", guiStyle );

The code is taken from Unity Answers.

I hope thins will help.