x


change Texture2d colors?

Hello. I am using this code for a load bar

private var barDisplay : float =.5 ;
 var barHealspeed : float = .02;
 private var pos : Vector2 = new Vector2(278,438);
private var size : Vector2 = new Vector2(123,14);
private var progressBarEmpty : Texture2D;
private var progressBarFull : Texture2D;

function OnGUI () {


 switch (currentPage) {

         case Page.Page1: Page1(); break;

         case Page.None: None(); break;
}
}



function Page1 () {

// draw the background:
GUI.BeginGroup (new Rect (pos.x, pos.y, size.x, size.y));
GUI.Box (Rect (0,0, size.x, size.y),progressBarEmpty);


// draw the filled-in part:
GUI.BeginGroup (new Rect (0, 0, size.x * barDisplay, size.y));
GUI.Box (Rect (0,0, size.x, size.y),progressBarFull);




//GUI.contentColor = color.yellow;// change text 
//GUI.backgroundColor = color.blue; // change button color
//GUI.color = color.green; // change text color


GUI.EndGroup ();
GUI.EndGroup ();

I've tried using the GUI.color codes up above to change colors, but they don't change the texture2d colors. Is there a way to change the bar's colors? And if so, then how do I plug it in? It's a bother because right now it is a dark gray color, and when it turns to night in my game or I am in dark area, you can't see the bar. I have two bars like this, and one I use for elemental attacks, the other is a force attack load bar. I really need to be able to change their colors specifically. Thanks for any help!

more ▼

asked Aug 01 '11 at 04:44 PM

superventure gravatar image

superventure
670 44 54 63

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You can change single pixels or blocks of pixels using the Texture2D functions (especially SetPixels, GetPixels), but I think for a progress bar there are much better solutions.

more ▼

answered Aug 01 '11 at 07:58 PM

sven1994 gravatar image

sven1994
291 2 3 10

I have no idea how they set that up in the docs, let alone how to apply the examples they gave to the code I am working with. Could you please provide an example? Why doesn't the load bar just change colors with the rest of buttons/texts with Gui.color commands anyway? Isn't the bar a gui built item?

Aug 02 '11 at 04:34 AM superventure
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x526
x455
x389
x369
x70

asked: Aug 01 '11 at 04:44 PM

Seen: 1519 times

Last Updated: Aug 02 '11 at 04:34 AM