- Home /
Question by
Oninji · Nov 25, 2010 at 11:00 PM ·
animationguiguitexture
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.
Comment
Best Answer
Answer by Oninji · Nov 25, 2010 at 11:17 PM
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);
Answer by oliver-jones · Nov 25, 2010 at 11:16 PM
Just take the value of your screen resolution, and divide it
(Screen.width /2), (Screen.height /2)
This will still position from it's top left point, but found how to do it. Thanks anyway.
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
HELP with scripting where GUI is involved 2 Answers
What's a good book to learn scripts for Unity? 1 Answer
Animate GUI Elements 1 Answer
UFPS:ultimate fps cameraGUI texture wont show in game 0 Answers