KMSelectable - Qkrisi/ktanemodkit GitHub Wiki

KMSelectable

[DisallowMultipleComponent]
public class KMSelectable : MonoBehaviour

Component that marks the object as an interactable object (button) for the game.


public KMSelectable Parent;

The parent of this selectable. This selectable will only be able to be clicked if its parent was clicked before. (leave it as null to mark it as not having a parent (modules or holdables), on a module the bomb will be its parent.)


public KMSelectable[] Children;

List of children selectables (All of the buttons on a module should be a child of the module itself)

Order is important as it is treated as a grid with row length defined by ChildRowLength.


public bool IsPassThrough;

Determines if this selectable is essentially a container, currently used for bomb faces.


public int ChildRowLength;

This is the number of selectables per row for gamepad controls.


public KMHighlightable Highlight;

The highlight of this selectable, becomes active when the selectable can be pressed.


public Collider[] SelectableColliders;

If you want to set the interaction colliders for mouse to something other than the highlight, you can set them here.


public int DefaultSelectableIndex = 0;

Allows you to set a particular child as the default index for gamepad controls.


public Action OnSelect;

Called whenever this selectable becomes the current selectable (highlighted).

CAUTION This behaves unintuitively, probably better to use OnHighlight or OnFocus instead.


public Action OnDeselect;

Called whenever this selectable stops being the current selectable (highlight ended).

CAUTION This behaves unintuitively, probably better to use OnHighlightEnded or OnDefocus instead.


public OnCancelHandler OnCancel;

Delegate fired when the player backs out of this selectable.

Delegate signature: delegate bool OnCancelHandler()

Return is whether it should drill out to parent.


public OnInteractHandler OnInteract;

Delegate fired when the player pushes the selectable (button down).

Delegate signature: delegate bool OnInteractHandler()

Return is whether it should drill in to children.


public Action OnInteractEnded;

Called when a player is interacting with this selectable and releases the mouse or controller button.


public Action OnHighlight;

Called when the highlight is turned on.


public Action OnHighlightEnded;

Called when the highlight is turned off.


public Action OnFocus;

Called when a module is focused, this is when it is interacted with from the bomb face level and this module's children can be selected.


public Action OnDefocus;

Called when a module is defocused, this is when a different selectable becomes the focus or the module has been backed out of.

CAUTION The game calls this method twice when it should only do so once. To work around this issue, refer to the Game Fixes manual!


public Action OnLeft;

Called when player pulls selection stick left while this selectable is focused.


public Action OnRight;

Called when player pulls selection stick right while this selectable is focused.


public bool AllowSelectionWrapX = false;

Determines whether gamepad selection should wrap around left/right.


public bool AllowSelectionWrapY = false;

Determines whether gamepad selection should wrap around up/down.


public void AddInteractionPunch(float intensityModifier = 1.0f)

Adds bomb movement (push) and controller vibration on interaction.


public void UpdateChildren(KMSelectable childToSelect = null)

Notifies the game that the children list has been updated.

Selects the child (if) specified as the current selectable.

CAUTION The game doesn't udpate the settings of children, so instantiated prefabs won't work with this method. To work around this issue, refer to the GameFixes manual!


public bool ForceSelectionHighlight = false;

Forces highlight to be selection highlight, this is yellow in game.

Should be used when interaction will drill down to child selectables.


public bool ForceInteractionHighlight = false;

Forces highlight to be interaction highlight, this is red in game.

Should be used when interaction will trigger a behavior.