private static void _SetSound(float size, FCMusciObject.MusicType m) { foreach (var k in mActiveMusic) { FCMusciObject fmo = k.Value; if (fmo.mMusicType == m) { fmo.nAudioSource.volume = fmo.GetCurValue() * size; } } }
public static FCMusciObject PlaySound(string name, bool loop, FCMusciObject.MusicType type = FCMusciObject.MusicType.Sound, string group = null, float len = 0, float startTime = 0, float volume = 1) { group = string.IsNullOrEmpty(group)? name : group; if (mActiveMusic.ContainsKey(group)) { StopSound(group); } if (!mAudioClipList.ContainsKey(name)) { AudioClip ac = LoadPrefab <AudioClip>(ResConfig.MUSIC_PATH + name); if (ac == null) { Debug.Log("<color=#660000>" + name + ":声音没有找到</color>"); return(null); } mAudioClipList[name] = ac; } FCMusciObject mo = null; if (mMusicPool.Count > 0) { mo = mMusicPool[0]; mMusicPool.RemoveAt(0); } else { mo = (FCMusciObject)CreateObject(ResConfig.CC_MUSICAUDION, Engine.gameObject); } if (mo != null) { mo.gameObject.SetActive(true); mActiveMusic[group] = mo; mo.gameObject.name = group; mo.SetCurValue(volume); mo.mMusicType = type; float v = 0; if (type == FCMusciObject.MusicType.Music) { v = mMusciSize.x; } else { v = mMusciSize.y; } mo.PlaySound(name, mAudioClipList[name], len, volume * v, startTime, loop); } return(mo); }
public FCMusciObject PlaySound(string name, bool loop, FCMusciObject.MusicType type = FCMusciObject.MusicType.Sound, string group = null, float len = 0, float startTime = 0, float volume = 1) { return(FEngineManager.PlaySound(name, loop, type, group, len, startTime, volume)); }