Initial commit - Unity game project
This commit is contained in:
44
Assets/Scripts/SimpleCrosshair.cs
Normal file
44
Assets/Scripts/SimpleCrosshair.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class SimpleCrosshair : MonoBehaviour
|
||||
{
|
||||
[Header("Crosshair Settings")]
|
||||
public Color crosshairColor = Color.white;
|
||||
public float crosshairSize = 10f;
|
||||
public float crosshairThickness = 2f;
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
// Calculate center of screen
|
||||
float centerX = Screen.width / 2f;
|
||||
float centerY = Screen.height / 2f;
|
||||
|
||||
// Set the crosshair color
|
||||
GUI.color = crosshairColor;
|
||||
|
||||
// Draw horizontal line
|
||||
GUI.DrawTexture(
|
||||
new Rect(
|
||||
centerX - crosshairSize / 2f,
|
||||
centerY - crosshairThickness / 2f,
|
||||
crosshairSize,
|
||||
crosshairThickness
|
||||
),
|
||||
Texture2D.whiteTexture
|
||||
);
|
||||
|
||||
// Draw vertical line
|
||||
GUI.DrawTexture(
|
||||
new Rect(
|
||||
centerX - crosshairThickness / 2f,
|
||||
centerY - crosshairSize / 2f,
|
||||
crosshairThickness,
|
||||
crosshairSize
|
||||
),
|
||||
Texture2D.whiteTexture
|
||||
);
|
||||
|
||||
// Reset GUI color
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user