Created
December 10, 2022 13:26
-
-
Save RimuruDev/d99ce55b0c42d9c4f597df842b4f8273 to your computer and use it in GitHub Desktop.
Drow Cursor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public sealed class CursorSettings : MonoBehaviour | |
{ | |
[SerializeField] private Camera _camera; | |
[Space] | |
[SerializeField] private CursorLockMode cursorLockMode = CursorLockMode.Locked; | |
[SerializeField] private string cursorTexture = "*"; | |
[SerializeField] private bool isCursorVisible = false; | |
private void Start() | |
{ | |
if (_camera == null) | |
_camera = Camera.main; | |
Cursor.lockState = cursorLockMode; | |
Cursor.visible = isCursorVisible; | |
} | |
private void OnGUI() => SightForShooting(); | |
private void SightForShooting() | |
{ | |
int size = 12; | |
float posX = _camera.pixelWidth / 2 - size / 4; | |
float posY = _camera.pixelHeight / 2 - size / 2; | |
DrawCursor(ref posX, ref posY, ref size); | |
void DrawCursor(ref float posX, ref float posY, ref int size) | |
{ | |
GUI.Label(new Rect(posX, posY, size, size), cursorTexture); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment