I try to change this code for project on Ipad, but i don’t work …
someone can help me?
thanks
using UnityEngine;
using System.Collections;
public class Fonction_Mesure : MonoBehaviour
{
public Vector3 screenSpace;
public Vector3 offset;
//Declaration des spheres
public GameObject Sphere1 ;
public GameObject Sphere2 ;
void OnMouseDown (){
//translate the cubes position from the world to Screen Point
screenSpace = Camera.main.WorldToScreenPoint(transform.localPosition);
//calculate any difference between the cubes world position and the mouses Screen position converted to a world point
offset = transform.localPosition - Camera.main.ScreenToWorldPoint( new Vector2(Input.mousePosition.x,Input.mousePosition.y));
}
/*
OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse.
OnMouseDrag is called every frame while the mouse is down.
*/
void OnMouseDrag (){
//keep track of the mouse position
Vector2 curScreenSpace = new Vector2(Input.mousePosition.x,Input.mousePosition.y);
//convert the screen mouse position to world point and adjust with offset
Vector3 curPosition= Camera.main.ScreenToWorldPoint(curScreenSpace) + offset;
//update the position of the object in the world
transform.localPosition = curPosition;
}
}