Animator Override Controller Learning and performance testing

Source: Internet
Author: User

This article by Bo Master (Yinapan) original, reprint please indicate source: http://www.cnblogs.com/xsln/p/Animator_Override_Controller.html

First, Animator Override Controller introduction:An animated overlay is a class of asset that allows you to expand an existing animation controller with a specific animations, but retains the original structure, parameters, and logic;

This allows you to create multiple variants of the same basic state machine, which use different animations.

For example: You have a series of NPCs live in the game, they have their own unique walk, idle, wait animations, create a basic animation controller, containing all kinds of NPC logic,

You can create an override for each NPC, and then use their respective animation to populate;

Second, the production method:

Icon: With + sign for override Controller

1. Create select animator Override Controller

2. Change the name to M2_P01

3, the original Animtorcontroller dragged into the controller, that is, the completion of production!

Third, the use and this[] performance test

1 usingUnityengine;2 usingSystem.Collections;3 4  Public classAnimatoroverideperformance:monobehaviour {5      Public BOOLM_test =true;6Animator M_animator =NULL;7Animatoroverridecontroller M_old =NULL;8Animatoroverridecontroller m_new =NULL;9 Ten     //Use this for initialization One     voidStart () { AM_animator = getcomponent<animator>(); -M_old =NewAnimatoroverridecontroller (); -M_new = resources.load<animatoroverridecontroller> ("packages/artworks/player/m2/m2_p04/m2_p04"); the 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"]; ADebug.logerror (m_old["p01attack01"]); atDebug.logerror (m_old["p01attack02"]); -         }         -     } -  -     voidUpdate () { -Profiler.beginsample ("Update"); in         if(M_test &&m_new) { -Profiler.beginsample ("this[]"); tom_old["p01attack01"] = m_new["p04attack01"]; +m_old["p01attack02"] = m_new["p04attack02"]; - profiler.endsample (); the         } * profiler.endsample (); $     }Panax Notoginseng  -}
View CodeTest Result: Single fetch and set consumption is about 0.5~1ms;

Animator Override Controller Learning and performance testing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.