Next: , Previous: , Up: Interaction   [Contents][Index]


9.9 Key Toggle

Component: KeyToggle

This component allows objects, colliders, renderers, and scripts to be toggled based on the state of a given key. Off key is read on key up, On key is read on key down. This prevents key collisions when using the same key for both. If you want these objects and components to start in a ’Toggled off’ state, set ’Toggle’ to false, otherwise they will be enabled automatically when the game starts. It may be more convenient to use this component than using a Message Toggle and Key Message in some situations.

Field of KeyToggle: GameObject[] gameObjectTargets

Game Objects we will toggle

Field of KeyToggle: MonoBehaviour[] scriptTargets

Scripts we will toggle

Field of KeyToggle: Collider colliderTarget

Collider we will toggle

Field of KeyToggle: MeshRenderer rendererTarget

Render we will toggle

Input Settings

Field of KeyToggle: KeyCode off

Key to be pressed to toggle off

Default value: KeyCode.LeftControl

Field of KeyToggle: KeyCode on

Key to be released to toggle on

Default value: KeyCode.LeftControl

Field of KeyToggle: KeyCode swapKey

Key to be tapped to swap the toggle

Default value: KeyCode.None

Field of KeyToggle: bool reverse

Should we swap off/on?

Default value: false

Field of KeyToggle: bool toggle

Are we currently toggled?

Default value: true

Field of KeyToggle: GameObject[] gameObjectTargets

Game Objects we will toggle

Field of KeyToggle: MonoBehaviour[] scriptTargets

Scripts we will toggle

Field of KeyToggle: Collider colliderTarget

Collider we will toggle

Field of KeyToggle: MeshRenderer rendererTarget

Render we will toggle

Input Settings

Field of KeyToggle: KeyCode off

Key to be pressed to toggle off

Default value: KeyCode.LeftControl

Field of KeyToggle: KeyCode on

Key to be released to toggle on

Default value: KeyCode.LeftControl

Field of KeyToggle: KeyCode swapKey

Key to be tapped to swap the toggle

Default value: KeyCode.None

Field of KeyToggle: bool reverse

Should we swap off/on?

Default value: false

Field of KeyToggle: bool toggle

Are we currently toggled?

Default value: true


Next: , Previous: , Up: Interaction   [Contents][Index]