浏览代码

add set animator parameter action

/main
Laurent 5 年前
当前提交
32ec1ac6
共有 2 个文件被更改,包括 78 次插入0 次删除
  1. 67
      Runtime/LevelScripting/Actions/SetAnimatorParameterAction.cs
  2. 11
      Runtime/LevelScripting/Actions/SetAnimatorParameterAction.cs.meta

67
Runtime/LevelScripting/Actions/SetAnimatorParameterAction.cs


using UnityEngine;
using NaughtyAttributes;
public enum AnimatorParameterType { Bool, Float, Int, Trigger };
namespace GameplayIngredients.Actions
{
public class SetAnimatorParameterAction : ActionBase
{
public Animator animator;
public string parameterName;
[OnValueChanged("OnParameterTypeChanged")]
public AnimatorParameterType parameterType;
bool showFloat;
bool showInt;
bool showBool = true;
[ShowIf("showFloat")]
public float floatValue;
[ShowIf("showInt")]
public int intValue;
[ShowIf("showBool")]
public bool boolValue;
public override void Execute(GameObject instigator = null)
{
if (animator == null)
return;
switch (parameterType)
{
case AnimatorParameterType.Bool:
animator.SetBool(parameterName, boolValue);
break;
case AnimatorParameterType.Float:
animator.SetFloat(parameterName, floatValue);
break;
case AnimatorParameterType.Int:
animator.SetInteger(parameterName, intValue);
break;
case AnimatorParameterType.Trigger:
animator.SetTrigger(parameterName);
break;
}
}
private void OnParameterTypeChanged()
{
showBool = false;
showFloat = false;
showInt = false;
switch (parameterType)
{
case AnimatorParameterType.Bool:
showBool = true;
break;
case AnimatorParameterType.Float:
showFloat = true;
break;
case AnimatorParameterType.Int:
showInt = true;
break;
}
}
}
}

11
Runtime/LevelScripting/Actions/SetAnimatorParameterAction.cs.meta


fileFormatVersion: 2
guid: e5f9a6ca2faa0514095c2a061d47807e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存