You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1023 B
34 lines
1023 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class HomographyCorner : MonoBehaviour
|
|
, IDragHandler
|
|
{
|
|
// [AutoUI]
|
|
public Vector2 position;
|
|
|
|
private RectTransform draggingPlane;
|
|
|
|
public void OnDrag(PointerEventData eventData)
|
|
{
|
|
if (eventData.pointerEnter != null && eventData.pointerEnter.transform as RectTransform != null)
|
|
draggingPlane = eventData.pointerEnter.transform as RectTransform;
|
|
|
|
var rt = GetComponent<RectTransform>();
|
|
Vector3 globalMousePos;
|
|
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(draggingPlane, eventData.position, eventData.pressEventCamera, out globalMousePos))
|
|
{
|
|
rt.position = globalMousePos;
|
|
position = globalMousePos;
|
|
//rt.rotation = draggingPlane.rotation;
|
|
}
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
var rt = GetComponent<RectTransform>();
|
|
rt.position = position;
|
|
}
|
|
}
|
|
|