void Awake(){ if(type==_AniType.None) return; unitCreep=gameObject.GetComponent<UnitCreep>(); if(type==_AniType.Legacy){ aniInstance=aniRootObj.GetComponent<Animation>(); if(aniInstance!=null){ InitAnimation(); unitCreep.SetAnimationComponent(this); } } if(type==_AniType.Mecanim){ if(anim==null) anim=aniRootObj.GetComponent<Animator>(); if(anim!=null) unitCreep.SetAnimationComponent(this); AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = anim.runtimeAnimatorController; //overrideController["Assigned Animation Clip Name In The Controller"] = New Clip To Be Assigned; //overrideController["DummySpawn"] = clipSpawn!=null ? clipSpawn : null; overrideController["DummyMove"] = clipMove!=null ? clipMove : null; overrideController["DummyDestination"] = clipDestination!=null ? clipDestination : null; overrideController["DummyDestroyed"] = clipDead!=null ? clipDead : null; //if no spawn animation has been assigned, use move animation instead otherwise there will be an delay, bug maybe? AnimationClip spawn = clipSpawn!=null ? clipSpawn : clipMove; overrideController["DummySpawn"] = spawn!=null ? spawn : null; anim.runtimeAnimatorController = overrideController; } }
void Awake() { if (type == _AniType.None) { return; } unitCreep = gameObject.GetComponent <UnitCreep>(); if (type == _AniType.Legacy) { aniInstance = aniRootObj.GetComponent <Animation>(); if (aniInstance != null) { InitAnimation(); unitCreep.SetAnimationComponent(this); } } if (type == _AniType.Mecanim) { if (anim == null) { anim = aniRootObj.GetComponent <Animator>(); } if (anim != null) { unitCreep.SetAnimationComponent(this); } AnimatorOverrideController overrideController = new AnimatorOverrideController(); overrideController.runtimeAnimatorController = anim.runtimeAnimatorController; //overrideController["Assigned Animation Clip Name In The Controller"] = New Clip To Be Assigned; //overrideController["DummySpawn"] = clipSpawn!=null ? clipSpawn : null; overrideController["DummyMove"] = clipMove != null ? clipMove : null; overrideController["DummyDestination"] = clipDestination != null ? clipDestination : null; overrideController["DummyDestroyed"] = clipDead != null ? clipDead : null; //if no spawn animation has been assigned, use move animation instead otherwise there will be an delay, bug maybe? AnimationClip spawn = clipSpawn != null ? clipSpawn : clipMove; overrideController["DummySpawn"] = spawn != null ? spawn : null; anim.runtimeAnimatorController = overrideController; } }