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


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

    然后,添加一个FollowPreviewPath.cs的脚本,放在你需要移动的主相机下,相机就会根据你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 == 1)
                {
                    startPosition = transform.position;
                    startRotation = transform.rotation;
                    currentPoint += 1;
                    Clamptmp = 0;
                }
            }
        }
    }
  • 相关阅读:
    zabbix执行远程命令
    zabbix监控主从同步
    s3fs+minio模拟挂载S3服务器到本地服务器
    PHP编译报错
    ldd可执行程序时返回not a dynamic executable
    Windows nessus安装
    Django数据库,在原有表中添加新字段
    docker安装fastdfs与java客户端测试
    Docker安装与启动
    2018HBCPC
  • 原文地址:https://www.cnblogs.com/yukiArea/p/9999495.html
Copyright © 2020-2023  润新知