Unity添加多个可视镜头Preview功能(二)

制作好并摆放好镜头以后,在Preview.cs里添加一个time单个镜头移动时间的变量,并在PreviewEditor下绘制在Inspector面板下。

Unity添加多个可视镜头Preview功能(二)

然后,添加一个FollowPreviewPath.cs的脚本,放在你需要移动的主相机下,相机就会根据你Preview的路径和时间进行移动。Unity添加多个可视镜头Preview功能(二)

Unity添加多个可视镜头Preview功能(二)

完成@_@!后续想新增一些功能再继续完善它...

using System.Collections;
using System.Collections.Generic;
using UnityEngine; public class FollowPreviewPath : MonoBehaviour {
public Camera followCamera;
public Preview[] Previews;
int currentPoint;
float Clamptmp; Vector3 startPosition;
Quaternion startRotation;
// Use this for initialization
void Start () {
startPosition = transform.position;
startRotation = transform.rotation;
} // Update is called once per frame
void Update()
{
if (currentPoint < Previews.Length)
{
Clamptmp = Mathf.Clamp01(Clamptmp += Time.deltaTime / Previews[currentPoint].time);
print(Clamptmp);
followCamera.transform.position = Vector3.Lerp(startPosition, Previews[currentPoint].transform.position, Clamptmp);
followCamera.transform.rotation = Quaternion.Lerp(startRotation, Previews[currentPoint].transform.rotation, Clamptmp);
if (Clamptmp == )
{
startPosition = transform.position;
startRotation = transform.rotation;
currentPoint += ;
Clamptmp = ;
}
}
}
}
上一篇:Mac OS 上 CRT 的终端设置


下一篇:HTML5 canvas save()和restore()方法讲解