August 2018
Intermediate to advanced
794 pages
28h 4m
English
We can reduce the Design-Time work for the metronome by making use of the Extension method presented in the Creating just-in-time AudioSource components at runtime through C# scripting recipe.
First, copy the ExtensionMethods.cs C# script class into your metronome project. Next, delete the two GameObjects in the scene containing AudioSource components, and instead declare two public variables for each AudioClip (). Finally, we just need to write an Awake() method that will create the required GameObjects in the scene containing AudioSource basic on the AudioClip variables (and making the basic beat quieter than the accented one):
void Awake() { audioSourceTickBasic ...Read now
Unlock full access