Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class MoveWindow : MonoBehaviour {
  5. public bool move;
  6. public float posX;
  7. public float posY;
  8. Vector3 distance;
  9. int movement = 2;
  10. int speed = 10;
  11. void Start()
  12. {
  13. move = false;
  14. }
  15. void Update()
  16. {
  17. if (move == true)
  18. {
  19. // * movement * speed * Time.deltaTime;
  20. distance = Camera.main.WorldToScreenPoint(transform.position);
  21. posX = Input.mousePosition.x - distance.x;
  22. posY = Input.mousePosition.y - distance.y;
  23. }
  24. else if (move == false)
  25. {
  26.  
  27. }
  28. }
  29. void OnMouseDown()
  30. {
  31. move = true;
  32. }
  33. void OnMouseUp()
  34. {
  35. move = false;
  36. }
  37. void OnMouseDrag()
  38. {
  39. Vector3 curPos = new Vector3(Input.mousePosition.x - posX, Input.mousePosition.y - posY, distance.z);
  40. Vector3 worldPos = Camera.main.ScreenToWorldPoint(curPos);
  41. transform.position = worldPos;
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement