56 lines
1.3 KiB
C#
56 lines
1.3 KiB
C#
using JetBrains.Annotations;
|
|
using Mirror;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
using UnityEngine;
|
|
|
|
public class AudioManager : MonoBehaviour
|
|
{
|
|
|
|
|
|
public AudioSource bgmAudioScource;
|
|
public static AudioManager Ins { get; private set; }
|
|
|
|
public List<AudioClip> audioClips;
|
|
|
|
public string[] ClipNames = { "bgm1", "bgm2", "bgm3", "playVoices_01" };
|
|
|
|
|
|
|
|
|
|
public Dictionary<string, AudioClip> clips = new Dictionary<string, AudioClip>();
|
|
|
|
|
|
private void Start()
|
|
{
|
|
Ins = this;
|
|
for (int i = 0; i < audioClips.Count; i++)
|
|
{
|
|
clips.Add(ClipNames[i], audioClips[i]);
|
|
}
|
|
|
|
//SoundServerToClientPlay("bgm1", true);
|
|
Debug.Log(clips);
|
|
SoundPlay("bgm1", true);
|
|
|
|
}
|
|
|
|
public void SoundPlay(string clipsName, bool isLoop)
|
|
{
|
|
//GameInit.Ins.bgm.loop = isLoop;
|
|
//GameInit.Ins.bgm.clip = clips[clipsName];
|
|
//GameInit.Ins.bgm.volume = 0.5f;
|
|
//GameInit.Ins.bgm.Play();
|
|
bgmAudioScource.loop = isLoop;
|
|
bgmAudioScource.clip = clips[clipsName];
|
|
bgmAudioScource.volume = 0.5f;
|
|
bgmAudioScource.Play();
|
|
}
|
|
public void SoundPlayOneShot(string clipsName, bool isLoop)
|
|
{
|
|
GameInit.Ins.sfx.loop = isLoop;
|
|
GameInit.Ins.sfx.PlayOneShot(clips[clipsName]);
|
|
}
|
|
}
|