天天看點

Unity - Timeline 之Creating a Timeline Asset and Timeline instance(建立Timeline Asset和Timeline 執行個體)Creating a Timeline Asset and Timeline instance

目錄:Unity - Timeline 知識彙總

原文:https://docs.unity3d.com/Packages/[email protected]/manual/wf_instance.html

翻譯時Timeline版本:Timeline 1.2.11

Creating a Timeline Asset and Timeline instance

建立Timeline Asset(Timeline資源)和Timeline instance執行個體

(這裡的Timeline Asset包括了:Timeline檔案,Timeline track中的clip,或是我們自定義腳本的PlayableAsset也算是Timeline Asset)

為了在你的場景中使用Timeline Asset,要在GameObject中使用Playable Director元件。Playable Director元件可以建立一個Timeline instance,并允許你指定一個場景中需要使用該Timeline處理動畫的對象。而這個被處理動畫的GameObject也必須要有 Animator 組将。

Timeline window将在你建立一個新的Timeline Asset(就是那個Playable Director)時自動建立Timeline instance。Timeline window也會建立必要的元件。

建立一個Timelien Asset和Timeline instance,需要以下步驟:

  1. 在你的場景中,選擇想要鏡頭對焦或是其他遊戲序列播放功能的GameObject。
  2. 打開Timeline window(菜單欄:Window>Sequencing>Timeline)。如果該GameObject還沒添加Playable Director元件,那麼Timeline window将提示你點選Create(建立)按鈕。
  3. 點選Create。将彈出對話框讓你給該Timeline Asset命名與存儲Timeline Asset的路徑。
  4. 點選Save(儲存)。
Unity - Timeline 之Creating a Timeline Asset and Timeline instance(建立Timeline Asset和Timeline 執行個體)Creating a Timeline Asset and Timeline instance

Timeline window 的一些工作流程:

  • 儲存新的Timeline Asset到你的Project的資源目錄。如果不調整你要儲存的Timeline Asset的名稱與儲存的資源路徑,Timeline window将建立一個基于你選擇的GameObject的名稱加上"Timeline"字尾的名稱。例如,你選擇了一個名詞為"Enemy"的GameObject,那麼将儲存Timeline Asset的資源名為:“EnemyTimeline”。
  • 添加空的Animation軌道到Timeline Asset。
  • 添加Playable Director 元件到你選中的GameObject,并給 Playable 屬性設定Timeline Assets。這将建立了一個Timeline instance。
  • 給選中的GameObject中的Playable Director元件設定Bindings中的Animation軌道資料。Animation track軌道沒有任何的剪輯動畫,是以選中的GameObject是沒有動畫的。
  • 添加Animator組将給選中的GameObject。Animator元件将通過Timeline instance來動畫驅動該GameObject。如果GameObject沒有Animator組将,将沒有動畫效果。

繼續閱讀