- Unity 2018 Cookbook(Third Edition)
- Matt Smith
- 160字
- 2025-02-23 18:56:40
Adding visualizations to the four playing loops
It's great fun to watch the visualization of the loop sounds as they play together. To add visualizations to the four AudioSources, all you have to do is:
- Import the SpectrumCubes.cs C# script file from the previous recipe into this project.
- Set the Main Camera Transform Position to (224, 50, -200).
- Set the Main Camera Camera component to have these settings: Projection = Perspective, Field of View 60, and Clipping Planes 0.3 - 300.
- Add a Directional Light GameObject to the scene.
- For each of the four GameObjects containing your AudioSources, add an instance of the SpectrumCubes script class.
- In the Inspector for the Spectrum Cubes (Script) component, change the displayColors for each AudioSource GameObject.
- Set the startY values of Spectrum Cubes (Script) components for the four GameObjects to be -50, 0, 50, 100. For most screen sizes, this should allow you too see all four visualization spectrums: