Scene Gizmo Drag 기능 #213
@@ -12,9 +12,9 @@ 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
|
||||||
, IPointerDownHandler, IPointerUpHandler
|
, IPointerDownHandler, IPointerUpHandler
|
||||||
#endif
|
#endif
|
||||||
@@ -53,7 +53,10 @@ 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 void Awake()
|
private Vector2 dragBeginPos;
|
||||||
|
private Vector2 curGizmoPos;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
{
|
{
|
||||||
imageHolderTR = (RectTransform) imageHolder.transform;
|
imageHolderTR = (RectTransform) imageHolder.transform;
|
||||||
controller = (SceneGizmoController) Instantiate( controller );
|
controller = (SceneGizmoController) Instantiate( controller );
|
||||||
@@ -96,9 +99,17 @@ namespace Studio.RuntimeGizmo
|
|||||||
m_onComponentClicked.Invoke( hitComponent );
|
m_onComponentClicked.Invoke( hitComponent );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDrag( PointerEventData eventData )
|
public void OnBeginDrag(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
dragBeginPos = eventData.position;
|
||||||
|
curGizmoPos = transform.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
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