纳金网
标题:
三个物体 一个球 一个cube 一个圆柱 点两个交换位置
[打印本页]
作者:
烟雨
时间:
2015-5-29 02:55
标题:
三个物体 一个球 一个cube 一个圆柱 点两个交换位置
三个物体 一个球 一个cube 一个圆柱 点两个交换位置
using UnityEngine;
using System.Collections;
public class GameController : MonoBehaviour {
public Transform first;
void Awake() {
first = null;
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0)) {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
Physics.Raycast(ray, out hit);
if (first == null) {
first = hit.transform;
}
else if (first != hit.transform) {
Vector3 temp = first.position;
first.position = hit.transform.position;
hit.transform.position = temp;
first = null;
}
}
}
}
复制代码
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5