Skip to content

Commit

Permalink
lab(Music): Music is now playable inside Lab.
Browse files Browse the repository at this point in the history
  • Loading branch information
JaXt0r committed Mar 6, 2024
1 parent eb09cf8 commit 31f759c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Assets/GothicVR-Lab/Scripts/Handler/LabMusicHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using GVR.Debugging;
using GVR.Manager;
using TMPro;
using UnityEngine;
Expand All @@ -26,7 +27,14 @@ public void Bootstrap()

public void MusicPlayClick()
{
MusicManager.I.SetMusic(fileSelector.itemText.text, themeSelector.itemText.text);
MusicManager.I.SetEnabled(true);
FeatureFlags.I.enableMusic = true;
FeatureFlags.I.showMusicLogs = true;

var fileSelect = fileSelector.options[fileSelector.value].text;
var themeSelect = fileSelector.options[fileSelector.value].text;

MusicManager.I.SetMusic(fileSelect, themeSelect);
}
}
}
7 changes: 6 additions & 1 deletion Assets/GothicVR/Scripts/Manager/MusicManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class MusicManager : SingletonBehaviour<MusicManager>
private IntPtr music;
private IntPtr directmusic;

[Flags]
public enum Tags : byte
{
Day = 0,
Expand Down Expand Up @@ -49,7 +50,7 @@ public enum Tags : byte
private void Start()
{
var backgroundMusic = GameObject.Find("BackgroundMusic");
backgroundMusic.TryGetComponent<AudioSource>(out musicSource);
backgroundMusic.TryGetComponent(out musicSource);
}


Expand Down Expand Up @@ -207,6 +208,10 @@ public void SetMusic(string segment, string themeName)
{
var theme = AssetCache.TryGetMusic(themeName);

reloadTheme = true;
pendingTheme = theme;
hasPending = true;

if (FeatureFlags.I.showMusicLogs)
Debug.Log($"Playing music: theme >{themeName}< from file >{theme.File}<");
}
Expand Down

0 comments on commit 31f759c

Please sign in to comment.