创建一个Cube挂在一个空物体下
using UnityEngine;
public class TestRotate : MonoBehaviour
{
public Transform Cube;
public Transform RotObj;
private float radius = 1080;
private Vector3 originalDir = new Vector3(0f, 0f, 1080f);
private Vector3 CenterPos = new Vector3(0, 0, 0);
private Vector2 startPos;
private Vector2 tempPos;
private Vector3 tempVec;
private Vector3 normalAxis;
private float angle;
// Use this for initialization
void Start()
{
Cube = GameObject.Find("Cube").transform;
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
startPos = Input.mousePosition;
}
if (Input.GetMouseButton(0))
{
tempPos = Input.mousePosition;
float tempX = tempPos.x - startPos.x;
float tempY = -tempPos.y + startPos.y;
float tempZ = Mathf.Sqrt(radius * radius - tempX * te