x


Draw GUI texture from it's center point.

Hello,

Is there any way to draw a GUI texture from it's center point instead of it's upper left corner?

I'd need to do that for a scripted GUI animation.

Thank you.

more ▼

asked Nov 25 '10 at 11:00 PM

Oninji gravatar image

Oninji
332 43 47 50

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

2 answers: sort voted first

Found how, I negate my width and height position by half their equivalent in texture size.

GUI.DrawTexture(Rect(((Screen.width/2)-(tWidth/2)),((Screen.height/2)-(tHeight/2)),tWidth,tHeight), Texture, ScaleMode.ScaleToFit, true, 0.0f);
more ▼

answered Nov 25 '10 at 11:17 PM

Oninji gravatar image

Oninji
332 43 47 50

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

Just take the value of your screen resolution, and divide it

(Screen.width /2), (Screen.height /2)
more ▼

answered Nov 25 '10 at 11:16 PM

oliver-jones gravatar image

oliver-jones
2.5k 205 225 253

This will still position from it's top left point, but found how to do it. Thanks anyway.

Nov 25 '10 at 11:17 PM Oninji
(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:

x5068
x3772
x3678
x476

asked: Nov 25 '10 at 11:00 PM

Seen: 2975 times

Last Updated: Nov 25 '10 at 11:00 PM