Added custom cursor
This commit is contained in:
27
Assets/Scripts/FakeCursor.cs
Normal file
27
Assets/Scripts/FakeCursor.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class FakeCursor : MonoBehaviour
|
||||
{
|
||||
public Camera AttachedCamera;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Cursor.visible = false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Vector3 absolutePosition = new()
|
||||
{
|
||||
x = Input.mousePosition.x / Screen.width * 1920,
|
||||
y = Input.mousePosition.y / Screen.height * 1080,
|
||||
z = 5f
|
||||
};
|
||||
transform.position = AttachedCamera.ScreenToWorldPoint(absolutePosition);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Cursor.visible = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user