Advertisement
Guest User

test

a guest
Jan 31st, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1.  
  2. using UnityEngine;
  3. using System.Collections;
  4.  
  5. public class Hareket1 : MonoBehaviour {
  6.  
  7.     private Vector3 screenPoint ;
  8.     private Vector3 offset;
  9.     void  OnMouseDown (){ screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);
  10.         offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
  11.  
  12.     }
  13.     void  OnMouseDrag (){ Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
  14.         Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
  15.         transform.position = curPosition;
  16.     }
  17.     void Update () {
  18.  
  19.         if(Input.touchCount==2) {
  20.  
  21.             Application.LoadLevel(Application.loadedLevel);
  22.  
  23.                 }
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement