Scene Gizmo Drag 기능 #213
@@ -12,7 +12,7 @@ namespace Studio.RuntimeGizmo
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SceneGizmoRenderer : MonoBehaviour, IPointerClickHandler, IDragHandler
|
public class SceneGizmoRenderer : MonoBehaviour, IPointerClickHandler, IDragHandler, IBeginDragHandler
|
||||||
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBGL || UNITY_FACEBOOK || UNITY_WSA || UNITY_WSA_10_0
|
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBGL || UNITY_FACEBOOK || UNITY_WSA || UNITY_WSA_10_0
|
||||||
, IPointerEnterHandler, IPointerExitHandler
|
, IPointerEnterHandler, IPointerExitHandler
|
||||||
#else
|
#else
|
||||||
@@ -53,6 +53,9 @@ namespace Studio.RuntimeGizmo
|
|||||||
public ComponentClickedEvent OnComponentClicked { get { return m_onComponentClicked; } }
|
public ComponentClickedEvent OnComponentClicked { get { return m_onComponentClicked; } }
|
||||||
#pragma warning restore 0649
|
#pragma warning restore 0649
|
||||||
|
|
||||||
|
private Vector2 dragBeginPos;
|
||||||
|
private Vector2 curGizmoPos;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
imageHolderTR = (RectTransform) imageHolder.transform;
|
imageHolderTR = (RectTransform) imageHolder.transform;
|
||||||
@@ -96,8 +99,16 @@ namespace Studio.RuntimeGizmo
|
|||||||
m_onComponentClicked.Invoke( hitComponent );
|
m_onComponentClicked.Invoke( hitComponent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnBeginDrag(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
dragBeginPos = eventData.position;
|
||||||
|
curGizmoPos = transform.position;
|
||||||
|
}
|
||||||
|
|
||||||
public void OnDrag( PointerEventData eventData)
|
public void OnDrag( PointerEventData eventData)
|
||||||
{
|
{
|
||||||
|
Vector2 moveOffset = eventData.position - dragBeginPos;
|
||||||
|
transform.position = curGizmoPos + moveOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3 GetNormalizedPointerPosition( PointerEventData eventData )
|
private Vector3 GetNormalizedPointerPosition( PointerEventData eventData )
|
||||||
|
|||||||
Reference in New Issue
Block a user