unity之 PlayableGraph 動畫應用(一)


PlayableGraph 概述: PlayableGraph是一組動畫圖API 

PlayableGraph常用API:
PlayableGraph
AnimationPlayableOutput: IPlayableOutPut 輸出節點
AnimationMixerPlayable: Iplayable 動畫混合
AnimationClipPlayable: Iplayable 動畫剪輯

可借用第三方可視化工具:
graph-visualizer 插件 進行查看,下載自行百度

 

 

廢話不多說 ,直接上代碼:

 1 using UnityEngine;  2 using UnityEngine.Animations;  3 using UnityEngine.Playables;  4 
 5 public class TestPlayable : MonoBehaviour  6 {  7     private Animator m_Animator;  8 
 9  [SerializeField] 10     private AnimationClip m_AnimationClip; 11     private PlayableGraph m_PlayableGraph; 12     private AnimationPlayableOutput m_AnimationPlayableOutput; 13 
14     void Awake() 15  { 16         m_Animator = GetComponent<Animator>(); 17         //創建畫布
18         m_PlayableGraph = PlayableGraph.Create("testGraph"); 19         //為畫布創建一個輸出節點
20         m_AnimationPlayableOutput = AnimationPlayableOutput.Create(m_PlayableGraph, "OutPut", m_Animator); 21  Test1(); 22  } 23 
24     void Test1() 25  { 26         //畫布上創建一個動畫剪輯,作為輸入節點
27         AnimationClipPlayable animationClipPlayable = AnimationClipPlayable.Create(m_PlayableGraph, m_AnimationClip); 28         //連線(設置輸出節點的輸入源為動畫剪輯)
29         m_AnimationPlayableOutput.SetSourcePlayable(animationClipPlayable, 0); 30         //播放
31  m_PlayableGraph.Play(); 32  } 33 }

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM