Class InputInteractionResolver
Answers what an interaction is, from either side: the little that conflict detection needs out of an authored string, and what a live interaction instance is when one fires.
Implements
Inherited Members
Namespace: Scylla.Input
Assembly: ScyllaInput.dll
Syntax
public sealed class InputInteractionResolver : IDisposable
Remarks
Reading an interactions string means parsing it, and parsing allocates. The conflict scan compares every binding against every other and is measured against an allocation budget, so the parse happens once per distinct string and the result is memoized. This is the same shape as InputControlAliasResolver, for the same reason, and the two are meant to be read together.
The memo also has to be discarded when the project's interaction defaults change,
because an authored interaction that omits its duration takes the value from
InputSettings, and that is a live, writable property rather than a constant.
Version exists so a caller holding its own derived cache can tell.
Known limit. The invalidation hook is InputSystem.onSettingsChange,
which the settings object raises from its own property setters. Whether it also fires
when InputSystem.settings is replaced wholesale has not been confirmed. A project
that swaps its settings asset at run time may therefore keep the previous defaults until
something else invalidates, which is a stale warning rather than a wrong binding.
Fields
NAME_DEFAULT
What a fire with no authored interaction reports as its name.
Declaration
public const string NAME_DEFAULT = "Default"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
Not an empty string, so a log line or a UI label reads as a statement rather than as a gap.
Properties
Shared
Gets the resolver every conflict feed shares, so one memo serves all of them.
Declaration
public static InputInteractionResolver Shared { get; }
Property Value
| Type | Description |
|---|---|
| InputInteractionResolver |
Version
Gets a counter that changes whenever previously resolved signatures may be stale.
Declaration
public int Version { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Combine(in InputInteractionSignature, in InputInteractionSignature)
Combines the interactions a binding declares with the ones its action declares.
Declaration
public static InputInteractionSignature Combine(in InputInteractionSignature binding, in InputInteractionSignature action)
Parameters
| Type | Name | Description |
|---|---|---|
| InputInteractionSignature | binding | The binding's signature. |
| InputInteractionSignature | action | Its action's signature. |
Returns
| Type | Description |
|---|---|
| InputInteractionSignature | The signature describing what actually drives the binding. |
Remarks
Unity adds the two rather than letting one replace the other, so a binding and an action that both declare something produce two or more interactions on that binding. Two is already more than this code reasons about, which is why the combination needs no arithmetic: whichever side is empty yields the other, and neither being empty yields Multiple.
That is also what lets each string be memoized on its own. Keying the memo on the pair would mean building a composite key per binding, which is exactly the allocation this class exists to avoid.
Dispose()
Declaration
public void Dispose()
Invalidate()
Discards every resolved signature.
Declaration
public void Invalidate()
Resolve(string)
Resolves one authored interactions string.
Declaration
public InputInteractionSignature Resolve(string interactions)
Parameters
| Type | Name | Description |
|---|---|---|
| string | interactions | The string, or |
Returns
| Type | Description |
|---|---|
| InputInteractionSignature | Its signature. |
ResolveForBinding(InputAction, int)
Resolves what actually drives one binding of a live action.
Declaration
public InputInteractionSignature ResolveForBinding(InputAction action, int bindingIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| InputAction | action | The action the binding belongs to. |
| int | bindingIndex | Which of its bindings. |
Returns
| Type | Description |
|---|---|
| InputInteractionSignature | The signature, or the default when the index names nothing. |
Remarks
The one place that knows all three rules at once: a binding's own override replaces its authored string, the action's string is added to it, and a composite part carries none of its own but takes whatever its container has. A caller that assembled this itself would get the last of those wrong, because a part's authored interactions look usable and are silently ignored by Unity.
ResolveKind(IInputInteraction)
Reports which kind of interaction drove a fire.
Declaration
public static InputInteractionKind ResolveKind(IInputInteraction interaction)
Parameters
| Type | Name | Description |
|---|---|---|
| IInputInteraction | interaction | The interaction that fired, or |
Returns
| Type | Description |
|---|---|
| InputInteractionKind | The kind, or Default when there was none. |
Remarks
This asks a different question from ResolveForBinding(InputAction, int). That one says
what could drive a binding, read from what was authored, and answers
Multiple when an action declares two. This one
says what did drive one particular fire: Unity has already run its
disambiguation and handed over the single interaction that won, so the answer is
never Multiple.
An interaction a project registered itself reports Unknown. Use ResolveName(IInputInteraction) to tell two custom interactions apart.
ResolveName(IInputInteraction)
Reports the registered name of the interaction that drove a fire.
Declaration
public static string ResolveName(IInputInteraction interaction)
Parameters
| Type | Name | Description |
|---|---|---|
| IInputInteraction | interaction | The interaction that fired, or |
Returns
| Type | Description |
|---|---|
| string | The name, or NAME_DEFAULT when there was none. Never |
Remarks
The name as it would be authored, so HoldInteraction reports "Hold".
A custom interaction reports its own type name with the same suffix removed, which
is the only thing that separates one custom interaction from another once the kind
has collapsed them both to Unknown.