/// <summary> /// 替换现有音源 /// </summary> /// <param name="fileName"></param> /// <param name="fadeIn"></param> /// <param name="isLoop"></param> public void ChangeSound(string path, string fileName, float fadeIn, bool isLoop = false) { if (audioObjects.Count > 0) { string key = audioObjects.FirstOrDefault().Key; audioObjects[key].GetComponent <GalSound>().EndPlay(); //audioObjects.Remove(key); } GalSound gs = AddSound(fileName); string fullpath = path + "/" + fileName; SetSoundData(gs, fullpath, fadeIn, isLoop); }
public void SetSoundToMouth(string path, string fileName, float fadeIn, GameObject model, bool isLoop = false) { if (audioObjects.Count > 0) { string key = audioObjects.FirstOrDefault().Key; audioObjects[key].GetComponent <GalSound>().EndPlay(); //audioObjects.Remove(key); } GalSound gs = AddSound(fileName); string fullpath = path + "/" + fileName; SetSoundData(gs, fullpath, fadeIn, isLoop); Debug.Log("add mouth"); CubismAudioMouthInput ap = model.GetComponent <Live2dModel>().model.GetComponent <CubismAudioMouthInput>(); ap.AudioInput = gs.currentSource; }
private void SetSoundData(GalSound gs, string fileName, float fadeIn, bool isLoop) { gs.ap = this; gs.SetUserVolume(sm.masterVolume * groupVolume); gs.SetSoundData(fileName, fadeIn, isLoop); }