2019-12-03【Timeline|转自群友】Playabl

2019-12-03  本文已影响0人  持刀的要迟到了
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;  // Timeline相關
 
public class TimelineTool : MonoBehaviour{
    //放入帶有Playable Director的物件(Director用"Hold"模式)
    public PlayableDirector Director;
 
    void Update(){
        if (Input.GetKeyDown(KeyCode.A)){
            Director.Pause();           //先 Pause();
            StartCoroutine("tRewind"); //倒帶
        } 
    }
 
 
    //倒帶 ================================================================ 3
    public IEnumerator tRewind(){
        yield return new WaitForSeconds(0.001f * Time.deltaTime);
        Director.time -= 1.0f * Time.deltaTime;  //1.0f是倒帶速度
        Director.Evaluate();
        if (Director.time < 0f){
            Director.time = 0f;
            Director.Evaluate();
        }
        else {            
            StartCoroutine("tRewind");
        }
    }

上一篇下一篇

猜你喜欢

热点阅读