Quick-Start
- Make sure your project is set to build to the WebGL platform.
- Download Amplitude from the Unity Asset Store.
- Menu Select: Window > Asset Store > select your downloads
- Browse to: Amplitude > Import
- Create a new scene.
- Create a new Empty.
- Create a UI Slider so you can see the results in the WebGL build. You can position the sliders direction using the Slider Inspector.
- Create an AmplitudeTester.cs test script to link the Amplitude average output to the Unity UI Slider.
-
using UnityEngine; using UnityEngine.UI; using System.Collections; using CrazyMinnow.AmplitudeWebGL; public class AmplitudeTester : MonoBehaviour { public Amplitude amplitude; public Slider slider; void Update () { if (amplitude.audioSource.isPlaying) { slider.value = amplitude.average; } } }
-
- Add the following components to your Empty GameObject:
- Add an AudioClip to your AudioSource component, and check the boxes next to [Play On Awake] and [Loop].
- Link the AudioSource component to the Amplitude.audioSource public property.
- Link the Amplitude component to the AmplitudeTester.amplitude public property.
- Link the Unity UI Slider to the AmplitudeTester.slider public property.
- Build the scene to WebGL and enjoy!