Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class MoveWindow : MonoBehaviour {
- public bool move;
- public float posX;
- public float posY;
- Vector3 distance;
- int movement = 2;
- int speed = 10;
- void Start()
- {
- move = false;
- }
- void Update()
- {
- if (move == true)
- {
- // * movement * speed * Time.deltaTime;
- distance = Camera.main.WorldToScreenPoint(transform.position);
- posX = Input.mousePosition.x - distance.x;
- posY = Input.mousePosition.y - distance.y;
- }
- else if (move == false)
- {
- }
- }
- void OnMouseDown()
- {
- move = true;
- }
- void OnMouseUp()
- {
- move = false;
- }
- void OnMouseDrag()
- {
- Vector3 curPos = new Vector3(Input.mousePosition.x - posX, Input.mousePosition.y - posY, distance.z);
- Vector3 worldPos = Camera.main.ScreenToWorldPoint(curPos);
- transform.position = worldPos;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement