Enable Input Action#
Input / Enable Input Action
Description#
Enables an Input Action asset with an Action value which allows reading user input
Parameters#
| Name | Description |
|---|---|
| Input Asset | The Input Asset reference and Action name |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Enable Input Action")]
[Image(typeof(IconBoltOutline), ColorTheme.Type.Teal)]
[Description("Enables an Input Action asset with an Action value which allows reading user input")]
[Category("Input/Enable Input Action")]
[Parameter("Input Asset", "The Input Asset reference and Action name")]
[Keywords("Activate", "Active")]
[Serializable]
public class InstructionCoreInputEnableAction : Instruction
{
[SerializeField] private InputActionFromAsset m_InputAsset = new InputActionFromAsset();
protected override string GetTitle(GameObject source)
{
string input = TextUtils.ThemeAsConstant(this.m_InputAsset.ToString());
return $"Enable {input}";
}
protected override Awaitable Run(Args args)
{
UnityEngine.InputSystem.InputAction inputAction = this.m_InputAsset.InputAction;
if (inputAction is { enabled: false }) inputAction.Enable();
return Done;
}
}
}