public class shejian : MonoBehaviour {
RaycastHit pangzhaungdain;
bool show=false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButton (0)) {
Ray sx = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (sx, out pangzhaungdain) && (null != pangzhaungdain.collider))
show = true;
if (show) {
Vector3 currentposion = new Vector3 (sx.origin.x, sx.origin.y, transform.position.z);
transform.position = currentposion;
}
}else {
show = false;
}
}
}