首页 技术 正文
技术 2022年11月18日
0 收藏 522 点赞 3,974 浏览 1961 个字

本文由博主(YinaPan)原创,转载请注明出处:http://www.cnblogs.com/YinaPan/p/Unity_AnimatorOverrideContorller.html 

The Animator Override Controller is a type of asset which allows you to extend an existing Animator Controller, replacing the specific animations used but otherwise retaining the original’s structure, parameters and logic.

动画覆盖器是一类asset,它允许你扩张已经存在的动画控制器,用特定的animations 但是需要保留原始的结构、参数和逻辑;

This allows you to create multiple variants of the same basic state machine, but with each using different sets of animations.

这就允许你创建同一个基础状态机的多个变种,这些变种使用不同的animations

For example, your game may have a variety of NPC types living in the world, but each type (goblin, ogre, elf, etc) has their own unique animations for walking, idling, sitting, etc.

例如:你有一系列的npc生活在游戏中,他们有自己的独特走、idle、坐等animations;

By creating one “base” Animator Controller containing the logic for all NPC types, you could then create an override for each type and drop in their respective animation files.

To demonstrate, here’s a typical Animator Controller asset:

创建一个基础动画控制器,包含所有种类npc的逻辑,你就可以创建一个override为每一种NPC,然后用他们各自的animation去填充;

Animator Override Controllers 学习及性能测试

using UnityEngine;
using System.Collections;public class AnimatorOveridePerformance : MonoBehaviour {
public bool m_test = true;
Animator m_animator = null;
AnimatorOverrideController m_Old = null;
AnimatorOverrideController m_New = null; // Use this for initialization
void Start () {
m_animator = GetComponent<Animator>();
m_Old = new AnimatorOverrideController();
m_New = Resources.Load<AnimatorOverrideController>("Packages/ArtWorks/Player/M2/M2_P04/M2_P04");
Debug.LogError(m_New);
m_Old = (AnimatorOverrideController)m_animator.runtimeAnimatorController;
if (null != m_New) {
Debug.LogError(m_Old["P01Attack01"]);
Debug.LogError(m_Old["P01Attack02"]);
m_Old["P01Attack01"] = m_New["P04Attack01"];
m_Old["P01Attack02"] = m_New["P04Attack02"];
Debug.LogError(m_Old["P01Attack01"]);
Debug.LogError(m_Old["P01Attack02"]);
}
} void Update() {
Profiler.BeginSample("Update");
if (m_test && m_New) {
Profiler.BeginSample("this[]");
m_Old["P01Attack01"] = m_New["P04Attack01"];
m_Old["P01Attack02"] = m_New["P04Attack02"];
Profiler.EndSample();
}
Profiler.EndSample();
}}

单次消耗大概在0.5到1ms

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,084
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,559
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,408
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,181
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,818
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,901