Advertisement
Guest User

Untitled

a guest
Jan 25th, 2016
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. void OnMouseDown()
  2. {
  3. screenPoint = Camera.main.WorldToScreenPoint(transform.position);
  4.  
  5. offset = transform.position - Camera.main.ScreenToWorldPoint(
  6. new Vector3(Input.mousePosition.x, transform.position.y, transform.position.z));
  7. }
  8. void OnMouseDrag()
  9. {
  10. Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, transform.position.y, transform.position.z);
  11.  
  12. Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
  13. if (draggable)
  14. transform.position = curPosition;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement