2017-09-19 53 views

回答

1

默認情況下它是SDK您使用在運行時(紙板,Oculus公司,HTC萬歲,...)旋轉的攝像頭。

您可以使用腳本在編輯模式下旋轉相機。以下是一個示例,只需將此腳本分配給您的相機並按下左Ctrl,同時在編輯器窗口中移動鼠標:

public class EditorCameraController : MonoBehaviour 
{  
    public float sensitivityX = 15F; 
    public float sensitivityY = 15F; 
    public float minimumX = -360F; 
    public float maximumX = 360F; 
    public float minimumY = -60F; 
    public float maximumY = 60F; 
    private float rotationX = 0F; 
    private float rotationY = 0F; 
    private Quaternion originalRotation; 

    void Start() 
    { 
     originalRotation = transform.localRotation; 
    } 

    void Update() 
    { 
     if (Input.GetKey(KeyCode.LeftControl)) 
     { 
      rotationX += Input.GetAxis("Mouse X") * sensitivityX; 
      rotationY += Input.GetAxis("Mouse Y") * sensitivityY; 
      rotationX = ClampAngle(rotationX, minimumX, maximumX); 
      rotationY = ClampAngle(rotationY, minimumY, maximumY); 
      Quaternion xQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up); 
      Quaternion yQuaternion = Quaternion.AngleAxis(rotationY, -Vector3.right); 
      transform.localRotation = originalRotation * xQuaternion * yQuaternion; 
     } 
    } 

    public static float ClampAngle(float angle, float min, float max) 
    { 
     if (angle < -360F) 
     angle += 360F; 
     if (angle > 360F) 
     angle -= 360F; 
     return Mathf.Clamp(angle, min, max); 
    } 
}