Files
Shopping_UnityVR/Assets/02_Scripts/UI/BGMHud.cs

37 lines
835 B
C#

using System.Collections.Generic;
using UnityEngine;
public class BGMHud : MonoBehaviour
{
[SerializeField] private GameObject _contentRoot;
[SerializeField] private GameObject _contentPrefab;
private BGMBox currentBgm;
[SerializeField]private BGMClip DefaultBgm;
public void Start()
{
BGMBox[] BGMBoxs = GetComponentsInChildren<BGMBox>(true);
foreach (BGMBox bgm in BGMBoxs)
{
if(bgm._bgmClip == DefaultBgm)
{
bgm.PlayBGM();
currentBgm = bgm;
}
}
}
public void PlayPickBGM(GameObject buttonObj)
{
if(currentBgm != null)
currentBgm.StopBGM();
BGMBox bgmBox = buttonObj.GetComponentInParent<BGMBox>();
bgmBox.PlayBGM();
currentBgm = bgmBox;
}
}