- Home /
Crosshair help
How i make it so when i right click the crosshair goes away and when i let go from right click it comes back. Here crosshair script
var crosshairTexture : Texture2D;
var position : Rect;
function Start()
{
position = Rect( ( Screen.width - crosshairTexture.width ) / 2, ( Screen.height - crosshairTexture.height ) / 2, crosshairTexture.width, crosshairTexture.height );
}
function OnGUI()
{
GUI.DrawTexture(position, crosshairTexture);
}
Answer by FTheCloud · Aug 15, 2011 at 04:40 PM
var crosshairTexture : Texture2D; var position : Rect; var rightClick : boolean = true;
function Start() { position = Rect( ( Screen.width - crosshairTexture.width ) / 2, ( Screen.height - crosshairTexture.height ) / 2, crosshairTexture.width, crosshairTexture.height ); }
function Update() {
if(Input.GetMouseButtonDown(1)) { rightClick = false; } if(Input.GetMouseButtonUp(1)) { rightClick = true; } }
function OnGUI() { if(rightClick){ GUI.DrawTexture(position, crosshairTexture);
} }
Your answer
Follow this Question
Related Questions
Deadfrontier type crosshair 1 Answer
laser pointer 1 Answer
Rotate gun to mouselook 1 Answer
How to control opacity in Cross Hair? 1 Answer
Use IK or what? 1 Answer