Player Input Current Action Map#
Input / Player Input / Player Input Current Action Map
Can Read
Cannot Write
Description#
The name of the Input Action Map the Player Input is currently using
Code#
using System;
using UnityEngine;
using UnityEngine.InputSystem;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Player Input Current Action Map")]
[Category("Input/Player Input/Current Action Map")]
[Description("The name of the Input Action Map the Player Input is currently using")]
[Image(typeof(IconBoltOutline), ColorTheme.Type.Blue)]
[Keywords("Input", "Player", "Controls", "Map", "Actions")]
[Serializable]
public class TypeStringPlayerInputCurrentActionMap : TypeString
{
[SerializeField] private GetGameObject m_PlayerInput = new GetGameObject(
new GenTypeGameObject_PlayerInput()
);
public override string Get(Args args)
{
PlayerInput playerInput = this.m_PlayerInput.Get<PlayerInput>(args);
if (playerInput == null) return string.Empty;
InputActionMap actionMap = playerInput.currentActionMap;
return actionMap != null ? actionMap.name : string.Empty;
}
public override string ToString()
{
return $"{this.m_PlayerInput} Current Action Map";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}