Advertisement
jefflynch

FMod Playlist

Apr 20th, 2023
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1.     [SerializeField] EventReference m_BackgroundMusic;
  2.     private EventInstance _backgroundMusicEventInstance;
  3.  
  4.     PLAYBACK_STATE _playbackState;
  5.     private void Start()
  6.     {
  7.         _backgroundMusicEventInstance = RuntimeManager.CreateInstance(m_BackgroundMusic);
  8.        
  9.         _backgroundMusicEventInstance.start();
  10.     }
  11.  
  12.     private void Update()
  13.     {
  14.          _backgroundMusicEventInstance.getPlaybackState(out _playbackState);
  15.          
  16.             if (_playbackState == PLAYBACK_STATE.STOPPED)
  17.             {
  18.                 _backgroundMusicEventInstance.start();
  19.                 Debug.Log($"Restarting music");
  20.                 Debug.Log($"Playback state: {_playbackState}");
  21.             }
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement