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