Skip to content

Instantly share code, notes, and snippets.

View Rene-Damm's full-sized avatar
🖋️

Rene Damm Rene-Damm

🖋️
View GitHub Profile
@Rene-Damm
Rene-Damm / InputActionMockInput.cs
Created August 30, 2021 11:27
Setting up mock input for InputActions automatically
// Take a set of actions and create an InputDevice for it that has a control
// for each of the actions. Also binds the actions to that those controls.
public static InputDevice SetUpMockInputForActions(InputActionAsset actions)
{
var layoutName = actions.name;
// Build a device layout that simply has one control for each action in the asset.
InputSystem.RegisterLayoutBuilder(() =>
{
var builder = new InputControlLayout.Builder()
#pragma once
// This provides a library for stubbing and mocking C++ code as is. It works by requiring
// explicit hooks to be inserted into the code that is to be mocked. In a regular build,
// these hooks will do nothing. In a testing build, they will expand to calls into the
// framework here to allow the code being executed to be hijacked from outside.
//
// NOTE: Thread-safety! Arranging fakes must be done on a single thread. Using fakes can
// be done from multiple threads concurrently.
//