카테고리 없음
Mouse Pointer Free Aspect에서도 동작
기억해조
2022. 12. 14. 17:56
Free Aspect에서도 동작함
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InputManager : MonoBehaviour
{
public RectTransform pointerRectTrf;
public Canvas parentCanvas;
//Mouse Pointer 만들기
private void Update()
{
UpdateMousePos();
}
private void UpdateMousePos()
{
Vector2 movePos;
RectTransformUtility.ScreenPointToLocalPointInRectangle(
parentCanvas.transform as RectTransform,
Input.mousePosition, parentCanvas.worldCamera,
out movePos);
Vector3 mousePos = parentCanvas.transform.TransformPoint(movePos);
//Set fake mouse Cursor
pointerRectTrf.transform.position = mousePos;
}
}