Hi, I have a circle texture imported into unity for the crosshair. I have it become bigger every time you shoot. However, I don’t know how to make it so that it scales from the center and not from the top-right corner. Also, if it was imported as an image, can I still change the color with GUI.backgroundColor? I am asking this because when I imported it it became lighter. Thanks!
var crosshairTexture: Texture2D;
var crosshairPosition: Rect;
var crosshairActive = true;
var playerWalkScript: PlayerMovementScript;
var gunScript: GunScript;
function Start()
{
playerWalkScript = GameObject.FindWithTag("Player").GetComponent(PlayerMovementScript);
}
function Update()
{
gunScript = playerWalkScript.currentGun.GetComponent(GunScript);
crosshairPosition = Rect(((Screen.width ) / 2), ((Screen.height ) / 2), crosshairTexture.width * gunScript.currentAccuracy * 3, crosshairTexture.height * gunScript.currentAccuracy * 3);
}
function OnGUI()
{
if(crosshairActive == true)
{
GUI.DrawTexture(crosshairPosition, crosshairTexture);
}
if (gunScript.ammoClip == 0)
{
GUI.backgroundColor = Color.red;
}
}