To create a music-loop manager, perform the following steps:
- Create a new Unity 3D project and import the provided sound clip files.
- Create four GameObjects in the scene that contain an AudioSource component linked to a different AudioClip loop from the 140 bpm files provided. You can do this in a single step by dragging the music clip from the Project panel into either the Hierarchy panel or the Scene panel.
- In the Inspector panel, uncheck the Play On Awake parameter for all four AudioSource components (so that they don't start playing until we tell them to).
- Add a new empty GameObject named musicScheduler to the scene.
- Create a C# script class, called LoopScheduler, in a new folder, _Scripts, that contains the following code. Also, add an instance as a scripted component to the musicScheduler GameObject:
using UnityEngine; public class LoopScheduler : MonoBehaviour { public float bpm = 140.0F; public int numBeatsPerSegment...