zoukankan      html  css  js  c++  java
  • 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;
                }
            }
        }
    }
  • 相关阅读:
    web安全
    WCF通信架构
    WCF地址
    WCFContracts(契约)
    分布式中的王者WCF
    SOAP 介绍
    诊所管理软件
    MFC 画图CDC双缓冲
    Linux 启动、关闭、重启网络服务
    C# 除法的小数点问题
  • 原文地址:https://www.cnblogs.com/yukiArea/p/9999495.html
Copyright © 2011-2022 走看看