How do I center A GUI Texture in the exact middle of screen?

HI!! I have a GUI Texture That is 24 by 24.
How can I center it??

(Screen.width/2)-12, (Screen.height/2)-12

You are taking about a GUITexture not a texture drawn with GUI.DrawTexture. Right? If you create the default GUITexture (GameObject>Create Other>GUI Texture), it is centered in the screen. It is 128 x 58 in size. Take a look at their pixel settings:

  • X: -64
  • Y: -29
  • Width: 128
  • Height: 58

For your graphic, the settings would be:

  • X: -12
  • Y: -12
  • Width: 24
  • Height: 24

Then to center it, you set the Position at (0.5, 0.5, 0). GUITextures live in Viewport space where the bottom left corner is (0,0) and the upper right is (1,1), so (0.5,0.5) is the center of the screen. The Pixel Inset values set the anchor for the graphics.