66 lines
1.2 KiB
C#
66 lines
1.2 KiB
C#
// (c) Copyright HutongGames, LLC 2010-2016. All rights reserved.
|
|
|
|
using UnityEngine;
|
|
|
|
namespace HutongGames.PlayMaker.Actions
|
|
{
|
|
[ActionCategory(ActionCategory.Animator)]
|
|
[Tooltip("Returns the scale of the current Avatar for a humanoid rig, (1 by default if the rig is generic).\n The scale is relative to Unity's Default Avatar")]
|
|
public class GetAnimatorHumanScale: FsmStateAction
|
|
{
|
|
[RequiredField]
|
|
[CheckForComponent(typeof(Animator))]
|
|
[Tooltip("The Target. An Animator component is required")]
|
|
public FsmOwnerDefault gameObject;
|
|
|
|
[ActionSection("Result")]
|
|
|
|
[UIHint(UIHint.Variable)]
|
|
[Tooltip("the scale of the current Avatar")]
|
|
public FsmFloat humanScale;
|
|
|
|
Animator _animator;
|
|
|
|
public override void Reset()
|
|
{
|
|
gameObject = null;
|
|
humanScale= null;
|
|
}
|
|
|
|
public override void OnEnter()
|
|
{
|
|
// get the animator component
|
|
var go = Fsm.GetOwnerDefaultTarget(gameObject);
|
|
|
|
if (go==null)
|
|
{
|
|
Finish();
|
|
return;
|
|
}
|
|
|
|
_animator = go.GetComponent<Animator>();
|
|
|
|
if (_animator==null)
|
|
{
|
|
Finish();
|
|
return;
|
|
}
|
|
|
|
DoGetHumanScale();
|
|
|
|
Finish();
|
|
|
|
}
|
|
|
|
void DoGetHumanScale()
|
|
{
|
|
if (_animator==null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
humanScale.Value = _animator.humanScale;
|
|
}
|
|
|
|
}
|
|
} |