// EXECUTABLE: ---------------------------------------------------------------------------- public override bool InstantExecute(GameObject target, IAction[] actions, int index) { Character charTarget = this.character.GetCharacter(target); if (charTarget != null && this.prefabModel != null) { RuntimeAnimatorController runtimeController = null; CharacterAnimator targetCharAnim = charTarget.GetComponent <CharacterAnimator>(); if (targetCharAnim.animator != null) { runtimeController = targetCharAnim.animator.runtimeAnimatorController; Destroy(targetCharAnim.animator.gameObject); } GameObject instance = Instantiate <GameObject>(this.prefabModel, charTarget.transform); instance.name = this.prefabModel.name; instance.transform.localPosition = Vector3.zero; instance.transform.localRotation = Quaternion.identity; Animator instanceAnimator = instance.GetComponent <Animator>(); if (instanceAnimator != null) { targetCharAnim.animator = instanceAnimator; targetCharAnim.ResetControllerTopology(runtimeController); } } return(true); }
public override bool InstantExecute(GameObject target, IAction[] actions, int index) { Character _character = this.character.GetCharacter(target); if (_character == null) { return(true); } CharacterAnimator _animator = _character.GetCharacterAnimator(); if (_animator == null) { return(true); } if (this.state == null) { return(true); } _animator.ResetControllerTopology(this.state.GetRuntimeAnimatorController()); return(true); }