ITWEEN 相机运动 角色特写

using System.Collections;
public class CameraController : MonoBehaviour {
    public Transform[] movePath;
    public Transform[] lookPath;
    public Transform lookTarget;
    public float percentage;

    private float redPosition = .16f;
    private float bluePosition = .53f;
    private float greenPosition = 1;

    //gui styling
    public Font font;
    private GUIStyle style = new GUIStyle();

    void Start(){
        style.font=font;
    }

    void OnGUI(){
        percentage=GUI.VerticalSlider(
        new Rect(Screen.width-20,20,15,Screen.height-40),
        percentage,1,0);
        iTween.PutOnPath(gameObject,movePath,percentage);
        iTween.PutOnPath(lookTarget,lookPath,percentage);
        transform.LookAt(iTween.PointOnPath(lookPath,percentage));
        //
        if(GUI.Button(new Rect(5,Screen.height-25,50,20),"Red")){
            SlideTo(redPosition);
        }
        if(GUI.Button(new Rect(60,Screen.height-25,50,20),"Blue")){
            SlideTo(bluePosition);
        }
        if(GUI.Button(new Rect(115,Screen.height-25,50,20),"Green")){
            SlideTo(greenPosition);
        }
    }

    void OnDrawGizmos(){
        iTween.DrawPath(movePath,Color.magenta);
        iTween.DrawPath(lookPath,Color.cyan);
        Gizmos.color=Color.black;
        Gizmos.DrawLine(transform.position,lookTarget.position);
    }

    void SlideTo(float position){
        iTween.Stop(gameObject);
        iTween.ValueTo(gameObject,iTween.Hash("from",percentage,"to",position,"time",2,"easetype",iTween.EaseType.easeInOutCubic,"onupdate","SlidePercentage"));    
    }

    void SlidePercentage(float p){
        percentage=p;
    }
}

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值