Files
Inter-Face-Off/Assets/Scripts/FakeCursor.cs
2026-01-23 12:59:14 +00:00

28 lines
741 B
C#

using UnityEngine;
public class FakeCursor : MonoBehaviour
{
public RectTransform RectBounds;
public Camera AttachedCamera;
private void Start()
{
//Cursor.visible = false;
}
private void Update()
{
Vector2 size = new(Screen.width, Screen.height);
Vector2 hSize = new Vector2(AttachedCamera.pixelRect.width, AttachedCamera.pixelRect.height) / 2f;
Debug.Log(hSize);
Vector2 positionRelativeToMiddle = (size - hSize) + (Vector2)Input.mousePosition;
transform.position = AttachedCamera.ScreenToWorldPoint(new Vector3(positionRelativeToMiddle.x, positionRelativeToMiddle.y, 5f));
}
private void OnDestroy()
{
Cursor.visible = true;
}
}