|
|
|
|
|
|
|
|
|
|
void handleMouseMovement() { |
|
|
|
var pos = this.getPointPosition(Input.mousePosition); |
|
|
|
if (pos == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
physicalX: pos.x, |
|
|
|
physicalY: pos.y |
|
|
|
physicalX: pos.Value.x, |
|
|
|
physicalY: pos.Value.y |
|
|
|
)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
var pos = this.getPointPosition(Input.mousePosition); |
|
|
|
if (pos == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
pos.x, |
|
|
|
pos.y, |
|
|
|
pos.Value.x, |
|
|
|
pos.Value.y, |
|
|
|
InputUtils.getScrollButtonKey()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void OnPointerDown(PointerEventData eventData) { |
|
|
|
EventSystem.current.SetSelectedGameObject(this.gameObject, eventData); |
|
|
|
if (position == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
EventSystem.current.SetSelectedGameObject(this.gameObject, eventData); |
|
|
|
physicalX: position.x, |
|
|
|
physicalY: position.y |
|
|
|
physicalX: position.Value.x, |
|
|
|
physicalY: position.Value.y |
|
|
|
if (position == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
physicalX: position.x, |
|
|
|
physicalY: position.y |
|
|
|
physicalX: position.Value.x, |
|
|
|
physicalY: position.Value.y |
|
|
|
public Vector2 getPointPosition(PointerEventData eventData) { |
|
|
|
public Vector2? getPointPosition(PointerEventData eventData) { |
|
|
|
if (eventData.enterEventCamera == null && this.canvas.renderMode == RenderMode.ScreenSpaceCamera) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
Vector2 localPoint; |
|
|
|
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rectTransform, eventData.position, |
|
|
|
eventData.enterEventCamera, out localPoint); |
|
|
|
|
|
|
return localPoint; |
|
|
|
} |
|
|
|
|
|
|
|
public Vector2 getPointPosition(Vector2 position) { |
|
|
|
public Vector2? getPointPosition(Vector2 position) { |
|
|
|
Vector2 localPoint; |
|
|
|
Camera eventCamera = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (eventCamera == null && this.canvas.renderMode == RenderMode.ScreenSpaceCamera) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
RectTransformUtility.ScreenPointToLocalPointInRectangle(this.rectTransform, position, |
|
|
|
eventCamera, out localPoint); |
|
|
|
|
|
|
|
|
|
|
public void OnDrag(PointerEventData eventData) { |
|
|
|
var position = this.getPointPosition(eventData); |
|
|
|
if (position == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
physicalX: position.x, |
|
|
|
physicalY: position.y |
|
|
|
physicalX: position.Value.x, |
|
|
|
physicalY: position.Value.y |
|
|
|
var position = this.getPointPosition(eventData); |
|
|
|
if (position == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
var position = this.getPointPosition(eventData); |
|
|
|
physicalX: position.x, |
|
|
|
physicalY: position.y |
|
|
|
physicalX: position.Value.x, |
|
|
|
physicalY: position.Value.y |
|
|
|
var position = this.getPointPosition(eventData); |
|
|
|
if (position == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var position = this.getPointPosition(eventData); |
|
|
|
physicalX: position.x, |
|
|
|
physicalY: position.y |
|
|
|
physicalX: position.Value.x, |
|
|
|
physicalY: position.Value.y |
|
|
|
)); |
|
|
|
} |
|
|
|
|
|
|
|