Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnMouseDown()
- {
- screenPoint = Camera.main.WorldToScreenPoint(transform.position);
- offset = transform.position - Camera.main.ScreenToWorldPoint(
- new Vector3(Input.mousePosition.x, transform.position.y, transform.position.z));
- }
- void OnMouseDrag()
- {
- Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, transform.position.y, transform.position.z);
- Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
- if (draggable)
- transform.position = curPosition;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement