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