How to do it...

To schedule a sound to play after a given delay, do the following:

  1. Create a new Unity 2D project and import the provided sound clip files.
  2. Create a GameObject in the scene containing an AudioSource component linked to the metronome_tick AudioClip. This can be done in a single step by dragging the music clip from the Project panel into either the Hierarchy or Scene panels.
  3. Repeat the previous step to create another GameObject, containing an AudioSource linked to the metronome_tick_accent clip.
  1. For both AudioSources created, uncheck the Play Awake property  so these sounds do not begin playing as soon as the scene is loaded.
  2. Create an empty GameObject named MetronomeManager.
  3. Create a C# script class, Metronome, in a new ...

Get Unity 2018 Cookbook - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.