Created
April 8, 2021 11:09
-
-
Save silenciocorner/dec97e597c2691e6ea2d11719d934d97 to your computer and use it in GitHub Desktop.
Script Music.cs from Alessandro Fama article "Beat and Marker system with FMOD in Unity"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Music : MonoBehaviour | |
| { | |
| private FMOD.Studio.EventInstance instance; | |
| private BeatSystem bS; | |
| void Start() | |
| { | |
| bS = GetComponent<BeatSystem>(); | |
| } | |
| void Update() | |
| { | |
| if (Input.GetKeyDown(KeyCode.Space)) | |
| { | |
| instance = FMODUnity.RuntimeManager.CreateInstance("event:/music"); | |
| instance.start(); | |
| bS.AssignBeatEvent(instance); | |
| } | |
| if (Input.GetKeyDown(KeyCode.LeftControl)) | |
| { | |
| bS.StopAndClear(instance); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment