Crosshair not in middle :/ Please Help

Im trying to create a third person robot shooting game, but something is really fxxkin with me, its that i CAN NOT get the crosshair in the middle of the screen :frowning:

Heres the script:

using UnityEngine;
using System.Collections;

public class Crosshair : MonoBehaviour {
    public Texture2D InGameLogo;
    public Texture2D crosshair;

    // Use this for initialization
    void Start ()
    {
  
    }
  
    // Update is called once per frame
    void Update ()
    {
  
    }

    void OnGUI ()
    {
        GUI.Label (new Rect (Screen.width/2, Screen.height/2, 70, 70),crosshair);

        GUI.Box (new Rect (20,300,250,50), "ROBONIGGA! LETS GET IT!!!");

        GUI.DrawTexture (new Rect (20, 30, 250, 150), InGameLogo);


    }
}

Lol

Try:

GUI.Label (new Rect (Screen.width/2 - 35, Screen.height/2 - 35, 70, 70),crosshair);

Thanks, but its not quite in the middle.

Is your crosshair texture 70 x 70 pixels? Is your GUI skin’s label style offsetting the image?

You could always use GUI.DrawTexture(), which doesn’t use a GUI style:

GUI.DrawTexture(new Rect(Screen.width/2 - 35, Screen.height/2 - 35, 70, 70), crosshair);
1 Like

Oh DrawTexture did the trick lol. Thanks.

Happy to help!