Skip to content

InputLayer

Eric Lowry edited this page Nov 10, 2026 · 5 revisions

Namespace: Lowry.UI.InputLayers

public struct InputLayer : IComparable, IComparable<InputLayer>, IEquatable<InputLayer>

Represents an IL_Layer with an advanced custom inspector.

💡General Information

This structure is mainly for internal use, and it is unlikely that you will need to work with it directly.

Its main goal is to expose a custom property drawer for the Unity Inspector that can point to any IL_Layer you have configured within the InputLayers editor window.

This is a core component of the LayeredAction system.

📄Fields

name

public string name;

The name of the IL_Layer this is meant to represent.
Since layer names must be unique, this serves as the actual reference to the underlying IL_Layer.

📄Properties

_layer

public readonly IL_Layer _layer { get {...} }

Resolves name through GetLayerByName on each access. The lookup uses the manager's cache, not a reference stored in this struct. Returns null for a null, empty, or unknown name, or when the singleton is unavailable.

onActivated

public event Action onActivated { add {...} remove {...} }

Forwards subscriptions to _layer.onActivated. Adding or removing a handler requires a resolvable layer name.

onDeactivated

public event Action onDeactivated { add {...} remove {...} }

Forwards subscriptions to _layer.onDeactivated. Adding or removing a handler requires a resolvable layer name.

_priority

public readonly int? _priority { get {...} }

The cached zero-based index of this layer's IL_PriorityLayer within IL_ScriptableRefs.r_priorities.
Is null if the name cannot be resolved or the layer has no cached priority entry.

_isActive

public readonly bool _isActive { get {...} }

true when this layer is currently the unique active layer.

Security: Will return false on the same frame as the layer was activated on.
Otherwise, an input could be used to activate a layer, and then be triggered on that same layer immediately.

_isActiveUnsafe

public readonly bool _isActiveUnsafe { get {...} }

true when this layer is currently the unique active layer, even when called on the same frame the layer was activated on.

_isEnabled

public readonly bool _isEnabled { get {...} }

true when the resolved layer has a cached priority and is either the selected layer or present in that priority's activation stack. This check does not exclude the activation frame.
IMPORTANT: It may not be active. Returns false when the layer cannot be resolved or has no cached priority.

📄Methods

Activate()

public readonly bool? Activate () {...}

Tries to activate the _layer.

Returns:

  • true when the layer has been activated (or was already active).
  • false when the layer has not been activated (it will still be added to the relevant stack).
  • null when the name cannot be resolved or the resolved layer has no cached priority.

Deactivate()

public readonly void Deactivate () {...}

Removes the _layer from its activation stack and selects the top layer of the highest non-empty priority. Removing the selected layer notifies it of deactivation and any replacement of activation. If no layers remain, the selected layer and current priority become null. Removing a waiting layer does not invoke activation or deactivation events.

📄Constructors

InputLayer(string)

public InputLayer (string name_) {...}

Stores the layer name without validating or registering it. Use a non-empty name already present in the layer lookup cache to reference a configured layer.

InputLayer(IL_Layer)

public InputLayer (IL_Layer layer) {...}

Copies layer.name from a non-null IL_Layer; it does not retain the object reference or register the layer.

📒Notes

Equality, hashing, and comparisons use stored names with ordinal semantics; they do not resolve layers or require the singleton. Unknown names can be compared and hashed safely. Default-constructed InputLayer values have null names and compare equal to each other.

All CompareTo overloads use ordinal name ordering. The object overload accepts InputLayer and IL_Layer values, returns a positive value for null, and rejects unsupported types with ArgumentException. Comparing to a null IL_Layer also returns a positive value.

Cross-type == and != operators with IL_Layer compare the stored name to the non-null layer's name. A null IL_Layer is not equal to any InputLayer, including a default value. Equals(object) accepts only another InputLayer, preserving symmetric object equality; it returns false for null or an IL_Layer object.

A default-constructed InputLayer has a null name and is not a configured layer reference. Changing name after subscribing to events does not move the subscription to the new layer.

Clone this wiki locally