I need help with making a crosshair. Seriously I have no idea how to start. Please I need help if someone knows how and is willing to help please do because I rely need all the help with most of this as I can get.
Thanks, John
I need help with making a crosshair. Seriously I have no idea how to start. Please I need help if someone knows how and is willing to help please do because I rely need all the help with most of this as I can get.
Thanks, John
Mark fireDude67's answer as correct but here is how it should have properly been written
using UnityEngine;
using System.Collections;
public class Crosshair : MonoBehaviour {
public Texture image;
void OnGUI() {
GUI.DrawTexture(new Rect(Screen.width / 2, Screen.height / 2, image.width, image.height), image);
}
}
Just make a new csharp file named Crosshair and that will do the trick. fireDude was just missing a } and a )
First you will need a `Texture` to use as the crosshair image:
public Texture image;
Or in JavaScript:
var image : Texture
Then you will need to draw it:
void OnGUI() {
GUI.DrawTexture(new Rect(Screen.width / 2, Screen.height / 2, image.width, image.height);
}
JavaScript:
function OnGUI() {
GUI.DrawTexture(new Rect(Screen.width / 2, Screen.height / 2, image.width, image.height);
}
copy and paste this into a JavaScript:
var image : Texture;
function OnGUI() {
GUI.DrawTexture(new Rect(Screen.width / 2, Screen.height / 2, image.width, image.height);
}
C#:
public Texture image;
void OnGUI() {
GUI.DrawTexture(new Rect(Screen.width / 2, Screen.height / 2, image.width, image.height);
}