An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.2 KiB

// This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
// It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
using UnityEngine;
using UnityEngine.Serialization;
using Fungus.Variables;
namespace Fungus.Commands
{
/// <summary>
/// Resets a trigger parameter on an Animator component.
/// </summary>
[CommandInfo("Animation",
"Reset Anim Trigger",
"Resets a trigger parameter on an Animator component.")]
[AddComponentMenu("")]
[ExecuteInEditMode]
public class ResetAnimTrigger : Command
{
[Tooltip("Reference to an Animator component in a game object")]
[SerializeField] protected AnimatorData _animator;
[Tooltip("Name of the trigger Animator parameter that will be reset")]
[SerializeField] protected StringData _parameterName;
public override void OnEnter()
{
if (_animator.Value != null)
{
_animator.Value.ResetTrigger(_parameterName.Value);
}
Continue();
}
public override string GetSummary()
{
if (_animator.Value == null)
{
return "Error: No animator selected";
}
return _animator.Value.name + " (" + _parameterName.Value + ")";
}
public override Color GetButtonColor()
{
return new Color32(170, 204, 169, 255);
}
#region Backwards compatibility
[HideInInspector] [FormerlySerializedAs("animator")] public Animator animatorOLD;
[HideInInspector] [FormerlySerializedAs("parameterName")] public string parameterNameOLD = "";
protected virtual void OnEnable()
{
if (animatorOLD != null)
{
_animator.Value = animatorOLD;
animatorOLD = null;
}
if (parameterNameOLD != "")
{
_parameterName.Value = parameterNameOLD;
parameterNameOLD = "";
}
}
#endregion
}
}