🚀Quick Start

Setup

  1. Import the Thock asset into your Unity project.

  2. Add the Thock component to the GameObject where you want to handle the sound playing. Just use the Component menu or drag and drop the Thock prefab into the scene.

Configuration

  1. In the Thock component, assign a SoundPack_SO to the soundPack field. This is where you define what sound file to use and what keys trigger what sounds.

  2. If you want to use fallback keys (keys that play a random sound when pressed), set useFallbackKeys to true.

  3. Use the onKey event to define custom behavior when a key is pressed and a sound is played.

SoundPack_SO

The SoundPack_SO is a ScriptableObject where you define the sound file to use and the mapping of keys to sounds. Each key is associated with a Vector2Int, where the x value is the position in the sound file (in milliseconds) and the y value is the length of the sound (in milliseconds).

Generate New Sound Pack

You can generate a new SoundPack_SO directly from the Unity Editor. In the Thock component, enter the name of the new sound pack in the New Asset Name field and click the Generate New Sound Pack button. The new SoundPack_SO will be created in the SoundPacks directory.

Custom Editor

Thock comes with a custom editor that allows you to easily generate new sound packs and set up your key mappings. The custom editor is automatically used when you select a GameObject with the Thock component in the Unity Editor.

Last updated