Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7c9abaa
Add UsingActionsWorkflow.cs files
ChoshikaBagratee Aug 12, 2026
2cd98fb
Update UsingActionsWorkflowExamples.cs
ChoshikaBagratee Aug 12, 2026
bbe5f73
Fix code sample path
ChoshikaBagratee Aug 12, 2026
c84ae43
Add testable files
ChoshikaBagratee Aug 12, 2026
eb2f4b7
Merge branch 'docatt-11021-move-hardcoded-code-examples' of https://g…
ChoshikaBagratee Aug 12, 2026
910b276
add .cs files
ChoshikaBagratee Aug 13, 2026
8a42ed2
Add .cs files
ChoshikaBagratee Aug 13, 2026
f559f60
Add .cs files
ChoshikaBagratee Aug 21, 2026
f6bd4e0
add files
ChoshikaBagratee Aug 21, 2026
3fec92f
fix errors
ChoshikaBagratee Aug 21, 2026
eee8096
Delete ExternalSampleProjects/InputDeviceTester/Library/BurstCache/JI…
ChoshikaBagratee Aug 24, 2026
8c26080
add .meta files
ChoshikaBagratee Aug 24, 2026
a29a178
unity-meta changes
ChoshikaBagratee Aug 24, 2026
842edfd
fix compilation errors
ChoshikaBagratee Aug 24, 2026
03a03c9
Update ConfigureInputfromCode.cs
ChoshikaBagratee Aug 24, 2026
0dc4b2d
fix errors
ChoshikaBagratee Aug 24, 2026
8a92423
add xml comments
ChoshikaBagratee Aug 24, 2026
be4938f
fix errors
ChoshikaBagratee Aug 24, 2026
360f9f7
fix compile errors
ChoshikaBagratee Aug 24, 2026
6058449
Update CHANGELOG.md
ChoshikaBagratee Aug 24, 2026
579d446
Add changelog entry for Input Debugger fix
ChoshikaBagratee Aug 24, 2026
e76086c
Removing Library and UserSettings
josepmariapujol-unity Sep 14, 2026
22a4d78
Merge branch 'develop' into docatt-11021-move-hardcoded-code-examples
josepmariapujol-unity Sep 14, 2026
bb8b7d7
Fix typo
josepmariapujol-unity Sep 15, 2026
d08e70a
Fix typo
josepmariapujol-unity Sep 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using UnityEngine;
using UnityEngine.InputSystem;

/// <summary>
/// Example script demonstrating how to look up a project-wide action.
/// </summary>
public class AboutProjectWideActions : MonoBehaviour
{
void Start()
{
#region about-project-wide-actions
InputSystem.actions.FindAction("Move");
#endregion
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using UnityEngine;
using UnityEngine.InputSystem;

class BindingConflictsExample
{
public void Example()
{
#region bindingConflicts
// Create two actions in the same map.
var map = new InputActionMap();
var bAction = map.AddAction("B");
var shiftbAction = map.AddAction("ShiftB");

// Bind one of the actions to 'B' and the other to 'SHIFT+B'.
bAction.AddBinding("<Keyboard>/b");
shiftbAction.AddCompositeBinding("OneModifier")
.With("Modifier", "<Keyboard>/shift")
.With("Binding", "<Keyboard>/b");

// Print something to the console when the actions are triggered.
bAction.performed += _ => Debug.Log("B action performed");
shiftbAction.performed += _ => Debug.Log("SHIFT+B action performed");

// Start listening to input.
map.Enable();

var keyboard = Keyboard.current ?? InputSystem.AddDevice<Keyboard>();

// Now, let's assume the left shift key on the keyboard is pressed (here, we manually
// press it by queueing a state event for the control).
InputSystem.QueueDeltaStateEvent(keyboard.leftShiftKey, 1f);
InputSystem.Update();

// And then the B is pressed. This is a valid input for both
// bAction as well as shiftbAction.
//
// What will happen now is that shiftbAction will do its processing first. In response,
// it will *perform* the action (That is, we see the `performed` callback being invoked) and
// thus "consume" the input. bAction will stay silent as it will in turn be skipped over.
InputSystem.QueueDeltaStateEvent(keyboard.bKey, 1f);
InputSystem.Update();
#endregion
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
namespace DocCodeSamples.Tests
{
#region declaration
using UnityEngine;
using UnityEngine.InputSystem;

/// <summary>
/// Example script exposing serialized action references.
/// </summary>
public class ExampleScript : MonoBehaviour
{
/// <summary>
/// Reference to the "move" action.
/// </summary>
public InputAction move;

/// <summary>
/// Reference to the "jump" action.
/// </summary>
public InputAction jump;
}
#endregion

class ConfigureInputfromCode : MonoBehaviour
{
const string json = @"
{
""maps"" : [
{
""name"" : ""gameplay"",
""actions"" : [
{ ""name"" : ""fire"", ""type"" : ""button"" }
]
}
]
}";

void ConfigureFromJsonExample()
{
#region configurefromjson
// Load a set of action maps from JSON.
var maps = InputActionMap.FromJson(json);

// Load an entire InputActionAsset from JSON.
var asset = InputActionAsset.FromJson(json);
#endregion
}

void Start()
{
#region configurefromcode
{
// Create free-standing actions.
var lookAction = new InputAction("look", binding: "<Gamepad>/leftStick");
var moveAction = new InputAction("move", binding: "<Gamepad>/rightStick");

moveAction.AddCompositeBinding("1DAxis")
.With("Left", "<Keyboard>/a")
.With("Right", "<Keyboard>/d");
}

{
// Create an action map with actions.
var map = new InputActionMap("Gameplay");
var lookAction = map.AddAction("look");
lookAction.AddBinding("<Gamepad>/leftStick");
}

{
// Create an action asset.
var asset = ScriptableObject.CreateInstance<InputActionAsset>();
var gameplayMap = new InputActionMap("gameplay");
asset.AddActionMap(gameplayMap);
var lookAction = gameplayMap.AddAction("look", binding: "<Gamepad>/leftStick");
}
#endregion
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
namespace DocCodeSamples.Tests.ConfigureUnityEvents_ManualEnable
{
#region manualEnableSingleton
using UnityEngine;
using UnityEngine.InputSystem;

/// <summary>
/// Example script demonstrating manually enabling actions instead of using the
/// default project-wide action map.
/// </summary>
public class MyPlayerScript : MonoBehaviour
{
PlayerInput playerInput;

void Start()
{
playerInput = GetComponent<PlayerInput>();
InputSystem.actions.Disable();
playerInput.currentActionMap?.Enable();
}
}
#endregion
}

namespace DocCodeSamples.Tests.ConfigureUnityEvents_SendMessages
{
#region sendMessages
using UnityEngine;
using UnityEngine.InputSystem;

/// <summary>
/// Example script demonstrating the <c>PlayerInput</c> "Send Messages" behavior.
/// </summary>
public class MyPlayerScript : MonoBehaviour
{
// "jump" action becomes "OnJump" method.

/// <summary>
/// Called by <c>PlayerInput</c> when the "jump" action is triggered.
/// </summary>
// If you're not interested in the value from the control that triggers the action, use a method without arguments.
public void OnJump()
{
// your Jump code here
}

/// <summary>
/// Called by <c>PlayerInput</c> when the "move" action is triggered.
/// </summary>
/// <param name="value">Value of the control that triggered the action.</param>
// If you are interested in the value from the control that triggers an action, you can declare a parameter of type InputValue.
public void OnMove(InputValue value)
{
// Read value from control. The type depends on what type of controls.
// the action is bound to.
var v = value.Get<Vector2>();

// IMPORTANT:
// The given InputValue is only valid for the duration of the callback. Storing the InputValue references somewhere and calling Get<T>() later does not work correctly.
}
}
#endregion
}

namespace DocCodeSamples.Tests.ConfigureUnityEvents_InvokeUnityEvents
{
#region invokeUnityEvents
using UnityEngine;
using UnityEngine.InputSystem;

/// <summary>
/// Example script demonstrating the <c>PlayerInput</c> "Invoke Unity Events" behavior.
/// </summary>
public class MyPlayerScript : MonoBehaviour
{
/// <summary>
/// Called when the "fire" action is triggered.
/// </summary>
/// <param name="context">Context for the triggered action.</param>
public void OnFire(InputAction.CallbackContext context)
{
}

/// <summary>
/// Called when the "move" action is triggered.
/// </summary>
/// <param name="context">Context for the triggered action.</param>
public void OnMove(InputAction.CallbackContext context)
{
var value = context.ReadValue<Vector2>();
}
}
#endregion
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using UnityEngine;
using UnityEngine.InputSystem;

class ControlActuation : MonoBehaviour
{
void Example()
{
#region actuation
// Check if leftStick is currently actuated.
if (Gamepad.current.leftStick.IsActuated())
Debug.Log("Left Stick is actuated");
#endregion

#region actuation2
// Check if left stick is actuated more than a quarter of its motion range.
if (Gamepad.current.leftStick.EvaluateMagnitude() > 0.25f)
Debug.Log("Left Stick actuated past 25%");
#endregion
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Linq;
using UnityEngine;
using UnityEngine.InputSystem;

class ControlPathsExample
{
void Example()
{
#region parse
var parsed = InputControlPath.Parse("<XRController>{LeftHand}/trigger").ToArray();

Debug.Log(parsed.Length); // Prints 2.
Debug.Log(parsed[0].layout); // Prints "XRController".
Debug.Log(parsed[0].name); // Prints an empty string.
Debug.Log(parsed[0].usages.First()); // Prints "LeftHand".
Debug.Log(parsed[1].layout); // Prints null.
Debug.Log(parsed[1].name); // Prints "trigger".
#endregion

#region findcontrols
var gamepad = Gamepad.all[0];
var leftStickX = gamepad["leftStick/x"];
var submitButton = gamepad["{Submit}"];
var allSubmitButtons = InputSystem.FindControls("*/{Submit}");
#endregion
}

void PathExamples()
{
#region pathExamples
// Matches all gamepads (also gamepads *based* on the Gamepad layout):
_ = "<Gamepad>";
// Matches the "Submit" control on all devices:
_ = "*/";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above indicates this should match the Submit control across all devices, but the path is currently "*/".

Suggested change
_ = "*/";
// Matches the "Submit" control on all devices:
_ = "*/{Submit}";

🤖 Helpful? 👍/👎

// Matches the key that prints the "a" character on the current keyboard layout:
_ = "<Keyboard>/#(a)";
// Matches the X axis of the left stick on a gamepad.
_ = "<Gamepad>/leftStick/x";
// Matches the orientation control of the right-hand XR controller:
_ = "<XRController>/orientation";
// Matches all buttons on a gamepad.
_ = "<Gamepad>/<Button>";
#endregion
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using UnityEngine;
using UnityEditor;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Editor;

namespace DocCodeSamples.Tests
{
#region registernewprocessor
#if UNITY_EDITOR
[InitializeOnLoad]
#endif
/// <summary>
/// Example custom processor that registers itself with the Input System.
/// </summary>
public class MyValueShiftProcessor : InputProcessor<float>
{
#if UNITY_EDITOR
static MyValueShiftProcessor()
{
Initialize();
}

#endif

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void Initialize()
{
InputSystem.RegisterProcessor<MyValueShiftProcessor>();
}

/// <summary>
/// Returns <paramref name="value"/> unchanged.
/// </summary>
/// <param name="value">Value to process.</param>
/// <param name="control">Control from which the value originates.</param>
/// <returns>The unchanged value.</returns>
public override float Process(float value, InputControl control)
{
return value;
}
}
#endregion

class ProcessorExamples : MonoBehaviour
{
void Start()
{
#region inputactionwithprocessor
var action = new InputAction(processors: "myvalueshift(valueShift=2.3)");
#endregion
}

void ConfigureProcessorBinding()
{
#region processorbindings
var action = new InputAction();
action.AddBinding("<Gamepad>/leftStick")
.WithProcessor("invertVector2(invertX=false)");
#endregion
}

void AddProcessor()
{
#region addprocessor
var action = new InputAction(processors: "invertVector2(invertX=false)");
#endregion
}
}
}
Loading
Loading