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;
                }
            }
        }
    }
  • 相关阅读:
    字符串作为map的key
    类成员函数模板特化
    函数模板特化
    linux 下第一个Libevent代码学习
    linux下libevent安装
    随笔
    SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
    字符串处理总结之一(C#String类)
    XPath语法 在C#中使用XPath示例
    C#代码实现邮箱验证C#中及一些常用的正则表达式
  • 原文地址:https://www.cnblogs.com/yukiArea/p/9999495.html
Copyright © 2011-2022 走看看