unity之性能优化 PlayableGraph 动画应用(一)
2022/4/22 23:45:04
本文主要是介绍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 }
这篇关于unity之性能优化 PlayableGraph 动画应用(一)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-28微服务架构中API版本控制的实践
- 2024-09-28AI给的和自己写的Python代码,都无法改变输入框的内容,替换也不行
- 2024-09-27Sentinel配置限流资料:新手入门教程
- 2024-09-27Sentinel配置限流资料详解
- 2024-09-27Sentinel限流资料:新手入门教程
- 2024-09-26Sentinel限流资料入门详解
- 2024-09-26Springboot框架资料:初学者入门教程
- 2024-09-26Springboot框架资料详解:新手入门教程
- 2024-09-26Springboot企业级开发资料:新手入门指南
- 2024-09-26SpringBoot企业级开发资料新手指南