1.建立一个物品,一个画布以及一个相机
记得打开Gizmos
2.在Asset里面创造Render Texture,把camer的Target Texture设为该Render Texture
3.在画布下面创造将Raw Image,将Raw Image放在合适的位置,将RenderTexture的图片赋予它的TargetTexture.
4.然后创建一个空物体,使空物体位置与观察物体相同,调整相机的位置并且将相机作为它的子物体使相机可以绕着物体旋转
把旋转物体的脚本放在该物体身上就行了。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraRotation : MonoBehaviour
{
public float RotationSpeed = 5;
public float x;
public float y;
void Update()
{
y = Input.GetAxis("Horizontal");
x = Input.GetAxis("Vertical");
transform.Rotate(x * RotationSpeed, 0, y * RotationSpeed);
}
}