private void ShowSoundConnectionInfo(SoundConnection obj, bool editable) { EditorGUILayout.BeginVertical(); { SoundManager.PlayMethod playMethod = obj.playMethod; if (!editable) { EditorGUILayout.LabelField("Play Method: ", playMethod.ToString()); } else { playMethod = (SoundManager.PlayMethod)EditorGUILayout.EnumPopup("Play Method:", playMethod, EditorStyles.popup); if (playMethod != obj.playMethod) { SoundManagerEditorTools.RegisterObjectChange("Change Play Method", script); obj.playMethod = playMethod; EditorUtility.SetDirty(script); } } ShowMethodDetails(obj, editable, playMethod); EditorGUILayout.HelpBox(GetPlayMethodDescription(playMethod), MessageType.Info); ShowSongList(obj, editable); } EditorGUILayout.EndVertical(); }
/// <summary> /// Plays the SoundConnection right then, regardless of what you put at the level parameter of the SoundConnection. /// </summary> /// <param name='sc'> /// The SoundConnection. /// </param> /// <param name='syncPlaybackTime'> /// Whether the playback times should be synced. /// </param> /// <param name='trackNumber'> /// Track number to skip to, starting at 0. /// </param> public static void PlayConnection(SoundConnection sc, bool syncPlaybackTime = false, int trackNumber = 0) { int currentTimeSamples = 0; AudioSource currentSource = null; if (syncPlaybackTime) { currentSource = GetCurrentAudioSource(); if (currentSource != null) { currentTimeSamples = currentSource.timeSamples; } } for (int i = 0; i < trackNumber; i++) { Next(); } Instance._PlayConnection(sc); if (syncPlaybackTime) { currentSource = GetCurrentAudioSource(); if (currentTimeSamples > currentSource.clip.samples) { Debug.LogWarning("Your clips are not of equal length. SyncPlayback has restarted the new track"); currentTimeSamples = 0; } currentSource.timeSamples = currentTimeSamples; } }
void Start() { // How to initialize a SoundConnection sc = SoundManager.CreateSoundConnection("TemporarySoundConnection", SoundManager.PlayMethod.ContinuousPlayThrough, sample4, sample2, sample3, sample1); unitX = Screen.width / 48f; unitY = Screen.height / 30f; }
public void PlayConnection(SoundConnection connection) { if (connection == null) { return; } SoundManager.PlayConnection(connection); }
protected override void OnAllLoadEnd1() { base.OnAllLoadEnd1(); StartSoundConnection = CreateMainBGM(); CreditsSoundConnection = CreateCreditsBGM(); BattleSoundConnection = CreateBattleBGM(); StartMain(); }
/// <summary> /// Replaces the SoundConnection at that level. If a SoundConnection doesn't exist, it will just add it. /// </summary> /// <param name='sc'> /// The SoundConnection. /// </param> public static void ReplaceSoundConnection(SoundConnection sc) { int _indexOf = SoundConnectionsContainsThisLevel(sc.level); if (_indexOf != SOUNDMANAGER_FALSE) { RemoveSoundConnectionForLevel(sc.level); } AddSoundConnection(sc); }
/// <summary> /// Creates a SoundConnection. You can use a scene name or a custom name. Will default to ContinousPlayThrough. /// </summary> /// <returns> /// The SoundConnection. /// </returns> /// <param name='lvl'> /// The level name of the SoundConnection. /// </param> /// <param name='audioList'> /// Audio list. /// </param> public static SoundConnection CreateSoundConnection(string lvl, params AudioClip[] audioList) { SoundConnection sc = new SoundConnection(lvl, SoundManager.PlayMethod.ContinuousPlayThrough, audioList); if (!Application.CanStreamedLevelBeLoaded(lvl)) { sc.SetToCustom(); } return(sc); }
/// <summary> /// Creates a SoundConnection. You can use a scene name or a custom name. This overload is used for PlayMethods that use Random Delay In Range. /// </summary> /// <returns> /// The SoundConnection. /// </returns> /// <param name='lvl'> /// The level name of the SoundConnection. /// </param> /// <param name='method'> /// The PlayMethod. /// </param> /// <param name='minDelayPlay'> /// The minimum delay. /// </param> /// <param name='maxDelayPlay'> /// The maximum delay. /// </param> /// <param name='audioList'> /// Audio list. /// </param> public static SoundConnection CreateSoundConnection(string lvl, SoundManager.PlayMethod method, float minDelayPlay, float maxDelayPlay, params AudioClip[] audioList) { SoundConnection sc = new SoundConnection(lvl, method, minDelayPlay, maxDelayPlay, audioList); if (!Application.CanStreamedLevelBeLoaded(lvl)) { sc.SetToCustom(); } return(sc); }
// Use this for initialization protected override void Start() { base.Start(); m_maxSelection = GetListOfActiveButtons(); m_DelayManager = GetComponent <DelayManager>(); m_DelayManager.Reset(); m_myConnection = SoundManager.GetCurrentSoundConnection(); m_RoundMenu.SetActive(false); m_MatchMenu.SetActive(false); m_RoundPanel.SetActive(false); }
public void StartBGM(string musics) { if (musics.IsInv()) { return; } TempSoundConnection = null; TempSoundConnection = CreateConnection(new List <string>() { musics }); PlayConnection(TempSoundConnection); }
private void AddSound(SoundConnection obj, AudioClip clip) { if (clip == null) { return; } SoundManagerEditorTools.RegisterObjectChange("Add Sound", script); obj.soundsToPlay.Add(clip); EditorUtility.SetDirty(script); SceneView.RepaintAll(); }
private void RemoveSound(SoundConnection obj, int index) { if (obj.soundsToPlay[index] == null) { return; } SoundManagerEditorTools.RegisterObjectChange("Remove Sound", script); obj.soundsToPlay.RemoveAt(index); EditorUtility.SetDirty(script); SceneView.RepaintAll(); }
private void SwapSounds(SoundConnection obj, int index1, int index2) { if (obj.soundsToPlay[index1] == null || obj.soundsToPlay[index2] == null) { return; } SoundManagerEditorTools.RegisterObjectChange("Move Sounds", script); AudioClip tempClip = obj.soundsToPlay[index1]; obj.soundsToPlay[index1] = obj.soundsToPlay[index2]; obj.soundsToPlay[index2] = tempClip; EditorUtility.SetDirty(script); SceneView.RepaintAll(); }
/// <summary> /// Adds the SoundConnection to the manager. It will not add multiple SoundConnections to one level. /// </summary> /// <param name='sc'> /// The SoundConnection. /// </param> public static void AddSoundConnection(SoundConnection sc) { int _indexOf = SoundConnectionsContainsThisLevel(sc.level); if (_indexOf == SOUNDMANAGER_FALSE) { if (!Application.CanStreamedLevelBeLoaded(sc.level)) { sc.isCustomLevel = true; } Instance.soundConnections.Add(sc); } else { Debug.LogWarning("A SoundConnection for this level already exists. Remove it first."); } }
/// <summary> /// 请求语音聊天 /// </summary> private void toolStripButton3_Click(object sender, EventArgs e) { try { listBoxName(); //打开语音窗口 sound = new SoundConnection(userName, listBox1.SelectedItem.ToString(), multimediaManager, true); sound.Show(); //发送请求消息给对方 List <string> list = new List <string>(); list.Add(listBox1.SelectedItem.ToString()); list.Add(InformationTypes.SoundRequest.ToString()); dataProcessing.sendData(21, list); toolStripButton3.Enabled = false; soundReming(); } catch (Exception ee) { MessageBox.Show(ee.Message); } }
private void AddSoundConnection() { SoundManagerEditorTools.RegisterObjectChange("Add SoundConnection", script); SoundConnection sc = null; switch (playMethodToAdd) { case SoundManager.PlayMethod.ContinuousPlayThrough: case SoundManager.PlayMethod.OncePlayThrough: case SoundManager.PlayMethod.ShufflePlayThrough: sc = new SoundConnection(levelToAdd, playMethodToAdd, soundsToAdd.ToArray()); break; case SoundManager.PlayMethod.ContinuousPlayThroughWithDelay: case SoundManager.PlayMethod.OncePlayThroughWithDelay: case SoundManager.PlayMethod.ShufflePlayThroughWithDelay: sc = new SoundConnection(levelToAdd, playMethodToAdd, delayToAdd, soundsToAdd.ToArray()); break; case SoundManager.PlayMethod.ContinuousPlayThroughWithRandomDelayInRange: case SoundManager.PlayMethod.OncePlayThroughWithRandomDelayInRange: case SoundManager.PlayMethod.ShufflePlayThroughWithRandomDelayInRange: sc = new SoundConnection(levelToAdd, playMethodToAdd, minDelayToAdd, maxDelayToAdd, soundsToAdd.ToArray()); break; } if (isCustom) { sc.SetToCustom(); levelToAdd = defaultName; repaintNextFrame = true; } script.soundConnections.Add(sc); RecalculateBools(); EditorUtility.SetDirty(script); SceneView.RepaintAll(); }
/// <summary> /// Sets the current SoundConnection /// </summary> /// <param name='connection'> /// SoundConnection. /// </param> public static void SetCurrentSoundConnection(SoundConnection connection) { Instance.currentSoundConnection = connection; }
protected override void OnLuaParseEnd() { StartSoundConnection = CreateMainBGM(); CreditsSoundConnection = CreateCreditsBGM(); BattleSoundConnection = CreateBattleBGM(); }
public void StartBGM(List <string> musics) { TempSoundConnection = null; TempSoundConnection = CreateConnection(musics); PlayConnection(TempSoundConnection); }
private void SwapSounds(SoundConnection obj, int index1, int index2) { if(obj.soundsToPlay[index1] == null || obj.soundsToPlay[index2] == null) return; SoundManagerEditorTools.RegisterObjectChange("Move Sounds", script); AudioClip tempClip = obj.soundsToPlay[index1]; obj.soundsToPlay[index1] = obj.soundsToPlay[index2]; obj.soundsToPlay[index2] = tempClip; float tempBase = obj.baseVolumes[index1]; obj.baseVolumes[index1] = obj.baseVolumes[index2]; obj.baseVolumes[index2] = tempBase; EditorUtility.SetDirty(script); SceneView.RepaintAll(); }
private void ShowSongList(SoundConnection obj, bool editable) { int size = obj.soundsToPlay.Count; EditorGUILayout.LabelField("Sound List:"); EditorGUI.indentLevel++; for(int i = 0; i < size ; i++) { EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { if(!editable) { EditorGUILayout.LabelField(obj.soundsToPlay[i].name); } else { if(obj.soundsToPlay[i] == null) return; AudioClip newClip = (AudioClip)EditorGUILayout.ObjectField(obj.soundsToPlay[i], typeof(AudioClip), false); if(newClip != null) obj.soundsToPlay[i] = newClip; if(GUI.changed) { if(newClip == null) { RemoveSound(obj, i); return; } } bool oldEnabled = GUI.enabled; if(i == 0) GUI.enabled = false; if(GUILayout.Button("U", GUILayout.Width(35f))) { SwapSounds(obj, i, i-1); } GUI.enabled = oldEnabled; if(i == size-1) GUI.enabled = false; if(GUILayout.Button("D", GUILayout.Width(35f))) { SwapSounds(obj, i, i+1); } GUI.enabled = oldEnabled; GUI.color = Color.red; if(GUILayout.Button("-", GUILayout.Width(20f))) { RemoveSound(obj, i); return; } GUI.color = Color.white; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } if(editable) { EditorGUILayout.BeginHorizontal(); { EditorGUI.indentLevel++; editAddClip = EditorGUILayout.ObjectField("Add A Sound", editAddClip, typeof(AudioClip), false) as AudioClip; GUI.color = softGreen; if(GUILayout.Button("add", GUILayout.Width(40f))) { AddSound(obj, editAddClip); editAddClip = null; } GUI.color = Color.white; EditorGUI.indentLevel--; } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; }
public void Init(SoundConnection sC) { soundConnection = sC; }
void SetSoundConnection( int index, SoundConnection sc) { mObject.FindProperty(string.Format(mListData,index)).objectReferenceValue = sc; }
private void AddSound(SoundConnection obj, AudioClip clip) { if(clip == null) return; SoundManagerEditorTools.RegisterObjectChange("Add Sound", script); obj.soundsToPlay.Add(clip); obj.baseVolumes.Add(1f); EditorUtility.SetDirty(script); SceneView.RepaintAll(); }
private void ShowSoundConnectionInfo(SoundConnection obj, bool editable) { EditorGUILayout.BeginVertical(); { SoundManager.PlayMethod playMethod = obj.playMethod; if(!editable) { EditorGUILayout.LabelField("Play Method: ", playMethod.ToString()); } else { playMethod = (SoundManager.PlayMethod)EditorGUILayout.EnumPopup(new GUIContent("Play Method:", "Dictates how the SoundConnection will play through the sound list."), playMethod, EditorStyles.popup); if(playMethod != obj.playMethod) { SoundManagerEditorTools.RegisterObjectChange("Change Play Method", script); obj.playMethod = playMethod; EditorUtility.SetDirty(script); } } ShowMethodDetails(obj, editable, playMethod); EditorGUILayout.HelpBox(GetPlayMethodDescription(playMethod), MessageType.Info); ShowSongList(obj,editable); } EditorGUILayout.EndVertical(); }
public void StartMain() { PreBGMType = BGMType.MainMenu; PreSoundConnection = StartSoundConnection; PlayConnection(StartSoundConnection); }
public void StartCredits() { PreBGMType = BGMType.Credits; PreSoundConnection = CreditsSoundConnection; PlayConnection(CreditsSoundConnection); }
public void StartBattle() { PreBGMType = BGMType.Battle; PreSoundConnection = BattleSoundConnection; PlayConnection(BattleSoundConnection); }
private void ShowMethodDetails(SoundConnection obj, bool editable, SoundManager.PlayMethod method) { CheckUndo(); EditorGUI.indentLevel++; switch (method) { case SoundManager.PlayMethod.ContinuousPlayThrough: case SoundManager.PlayMethod.OncePlayThrough: case SoundManager.PlayMethod.ShufflePlayThrough: break; case SoundManager.PlayMethod.ContinuousPlayThroughWithDelay: case SoundManager.PlayMethod.OncePlayThroughWithDelay: case SoundManager.PlayMethod.ShufflePlayThroughWithDelay: if (!editable) { EditorGUILayout.LabelField("Delay:" + obj.delay + " second(s)"); } else { delayToEdit = obj.delay; #if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2) EditorGUI.BeginChangeCheck(); #endif delayToEdit = EditorGUILayout.FloatField("Delay:", delayToEdit); if (delayToEdit < 0) { delayToEdit = 0f; } #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 obj.delay = delayToEdit; #else if (EditorGUI.EndChangeCheck()) { Undo.RecordObjects(new Object[] { script }, "Modify Delay"); obj.delay = delayToEdit; EditorUtility.SetDirty(script); } #endif #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 if (GUI.changed) { if (!guiChanged && listeningForGuiChanges) { guiChanged = true; CheckUndo(); } guiChanged = true; EditorUtility.SetDirty(script); } #endif } break; case SoundManager.PlayMethod.ContinuousPlayThroughWithRandomDelayInRange: case SoundManager.PlayMethod.OncePlayThroughWithRandomDelayInRange: case SoundManager.PlayMethod.ShufflePlayThroughWithRandomDelayInRange: if (!editable) { EditorGUILayout.LabelField("Min Delay:" + obj.minDelay + " second(s)"); EditorGUILayout.LabelField("Max Delay:" + obj.maxDelay + " second(s)"); } else { minDelayToEdit = obj.minDelay; maxDelayToEdit = obj.maxDelay; #if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2) EditorGUI.BeginChangeCheck(); #endif minDelayToEdit = EditorGUILayout.FloatField("Minimum Delay:", minDelayToEdit); if (minDelayToEdit < 0) { minDelayToEdit = 0f; } #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 obj.minDelay = minDelayToEdit; #else if (EditorGUI.EndChangeCheck()) { Undo.RecordObjects(new Object[] { script }, "Modify Minimum Delay"); obj.minDelay = minDelayToEdit; EditorUtility.SetDirty(script); } #endif if (maxDelayToEdit < minDelayToEdit) { maxDelayToEdit = minDelayToEdit; } maxDelayToEdit = EditorGUILayout.FloatField("Maximum Delay:", maxDelayToEdit); if (maxDelayToEdit < 0) { maxDelayToEdit = 0f; } #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 obj.maxDelay = maxDelayToEdit; #else if (EditorGUI.EndChangeCheck()) { Undo.RecordObjects(new Object[] { script }, "Modify Maximum Delay"); obj.maxDelay = maxDelayToEdit; EditorUtility.SetDirty(script); } #endif #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 if (GUI.changed) { if (!guiChanged && listeningForGuiChanges) { guiChanged = true; CheckUndo(); } guiChanged = true; EditorUtility.SetDirty(script); } #endif } break; } EditorGUI.indentLevel--; }
private void ShowSoundConnection(int index) { GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); string status = SoundManager.HIDE; SoundConnection sc = script.soundConnections[index]; EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { status = script.songStatus[sc.level] as string; if (status == SoundManager.HIDE) { GUI.enabled = false; } if (icon) { GUILayout.Label(icon, GUILayout.ExpandWidth(false)); } GUI.enabled = true; if (sc.isCustomLevel) { EditorGUILayout.LabelField("<custom>" + sc.level); } else { EditorGUILayout.LabelField(sc.level); } if (status == SoundManager.HIDE && GUILayout.Button("view", GUILayout.Width(40f))) { script.songStatus[sc.level] = SoundManager.VIEW; } else if (status == SoundManager.VIEW) { GUI.color = Color.white; if (GUILayout.Button("hide", GUILayout.Width(40f))) { script.songStatus[sc.level] = SoundManager.HIDE; } } GUI.color = Color.cyan; if (status != SoundManager.EDIT && isEditing) { GUI.enabled = false; } if (status == SoundManager.HIDE && GUILayout.Button("edit", GUILayout.Width(40f))) { isEditing = true; script.songStatus[sc.level] = SoundManager.EDIT; delayToEdit = sc.delay; minDelayToEdit = sc.minDelay; maxDelayToEdit = sc.maxDelay; } else if (status == SoundManager.EDIT) { GUI.color = Color.white; if (GUILayout.Button("done", GUILayout.Width(40f))) { isEditing = false; script.songStatus[sc.level] = SoundManager.HIDE; } } GUI.enabled = true; GUI.color = Color.red; if (status == SoundManager.HIDE && GUILayout.Button("X", GUILayout.Width(25f))) { RemoveSoundConnection(index); return; } GUI.color = Color.white; } EditorGUILayout.EndHorizontal(); if (status != SoundManager.HIDE) { EditorGUI.indentLevel++; if (status == SoundManager.VIEW) { ShowSoundConnectionInfo(sc, false); } else if (status == SoundManager.EDIT) { ShowSoundConnectionInfo(sc, true); } EditorGUI.indentLevel--; } } EditorGUILayout.EndVertical(); }
private void AddSoundConnection() { SoundManagerEditorTools.RegisterObjectChange("Add SoundConnection", script); SoundConnection sc = null; switch (playMethodToAdd) { case SoundManager.PlayMethod.ContinuousPlayThrough: case SoundManager.PlayMethod.OncePlayThrough: case SoundManager.PlayMethod.ShufflePlayThrough: sc = new SoundConnection(levelToAdd, playMethodToAdd, soundsToAdd.ToArray()); break; case SoundManager.PlayMethod.ContinuousPlayThroughWithDelay: case SoundManager.PlayMethod.OncePlayThroughWithDelay: case SoundManager.PlayMethod.ShufflePlayThroughWithDelay: sc = new SoundConnection(levelToAdd, playMethodToAdd, delayToAdd, soundsToAdd.ToArray()); break; case SoundManager.PlayMethod.ContinuousPlayThroughWithRandomDelayInRange: case SoundManager.PlayMethod.OncePlayThroughWithRandomDelayInRange: case SoundManager.PlayMethod.ShufflePlayThroughWithRandomDelayInRange: sc = new SoundConnection(levelToAdd, playMethodToAdd, minDelayToAdd, maxDelayToAdd, soundsToAdd.ToArray()); break; } if(isCustom) { sc.SetToCustom(); levelToAdd = defaultName; repaintNextFrame = true; } script.soundConnections.Add(sc); RecalculateBools(); EditorUtility.SetDirty(script); SceneView.RepaintAll(); }
private void ShowSongList(SoundConnection obj, bool editable) { int size = obj.soundsToPlay.Count; EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(new GUIContent("Sound List:", "List of sounds in the SoundConnection. How they play is determined by the SoundConnection's PlayMethod. You can also assign the base volume of each sound.")); if(editable) { GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(new GUIContent("B-Vol:", "Base volume for an AudioClip in this SoundConnection. Lower this value if you don't want a particular AudioClip to play as loud. When in doubt, keep this at 1."), GUILayout.Width(65f)); EditorGUILayout.LabelField("", GUILayout.Width(90f)); } } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel++; for(int i = 0; i < size ; i++) { EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { if(!editable) { EditorGUILayout.LabelField(obj.soundsToPlay[i].name); } else { if(obj.soundsToPlay[i] == null) return; AudioClip newClip = (AudioClip)EditorGUILayout.ObjectField(obj.soundsToPlay[i], typeof(AudioClip), false, GUILayout.ExpandWidth(true)); if(newClip != null) obj.soundsToPlay[i] = newClip; if(GUI.changed) { if(newClip == null) { RemoveSound(obj, i); return; } } float baseVolume = obj.baseVolumes[i]; baseVolume = EditorGUILayout.FloatField(baseVolume, GUILayout.Width(55f)); if(baseVolume < 0f) baseVolume = 0f; else if (baseVolume > 1f) baseVolume = 1f; if(baseVolume != obj.baseVolumes[i]) { SoundManagerEditorTools.RegisterObjectChange("Change Base Volume", script); obj.baseVolumes[i] = baseVolume; EditorUtility.SetDirty(script); } bool oldEnabled = GUI.enabled; if(i == 0) GUI.enabled = false; if(GUILayout.Button("U", GUILayout.Width(35f))) { SwapSounds(obj, i, i-1); } GUI.enabled = oldEnabled; if(i == size-1) GUI.enabled = false; if(GUILayout.Button("D", GUILayout.Width(35f))) { SwapSounds(obj, i, i+1); } GUI.enabled = oldEnabled; GUI.color = Color.red; if(GUILayout.Button("-", GUILayout.Width(20f))) { RemoveSound(obj, i); return; } GUI.color = Color.white; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } if(editable) { EditorGUILayout.BeginHorizontal(); { EditorGUI.indentLevel++; editAddClip = EditorGUILayout.ObjectField("Add A Sound", editAddClip, typeof(AudioClip), false) as AudioClip; GUI.color = softGreen; if(GUILayout.Button("add", GUILayout.Width(40f))) { AddSound(obj, editAddClip); editAddClip = null; } GUI.color = Color.white; EditorGUI.indentLevel--; } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; }
private void RemoveSound(SoundConnection obj, int index) { if(obj.soundsToPlay[index] == null) return; SoundManagerEditorTools.RegisterObjectChange("Remove Sound", script); obj.soundsToPlay.RemoveAt(index); obj.baseVolumes.RemoveAt(index); EditorUtility.SetDirty(script); SceneView.RepaintAll(); }
private void ShowMethodDetails(SoundConnection obj, bool editable, SoundManager.PlayMethod method) { CheckUndo(); EditorGUI.indentLevel++; switch (method) { case SoundManager.PlayMethod.ContinuousPlayThrough: case SoundManager.PlayMethod.OncePlayThrough: case SoundManager.PlayMethod.ShufflePlayThrough: break; case SoundManager.PlayMethod.ContinuousPlayThroughWithDelay: case SoundManager.PlayMethod.OncePlayThroughWithDelay: case SoundManager.PlayMethod.ShufflePlayThroughWithDelay: if(!editable) EditorGUILayout.LabelField("Delay:" + obj.delay + " second(s)"); else { delayToEdit = obj.delay; #if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2) EditorGUI.BeginChangeCheck(); #endif delayToEdit = EditorGUILayout.FloatField("Delay:", delayToEdit); if(delayToEdit < 0) delayToEdit = 0f; #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 obj.delay = delayToEdit; #else if(EditorGUI.EndChangeCheck()) { Undo.RecordObjects(new Object[]{script}, "Modify Delay"); obj.delay = delayToEdit; EditorUtility.SetDirty(script); } #endif #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 if(GUI.changed) { if(!guiChanged && listeningForGuiChanges) { guiChanged = true; CheckUndo(); } guiChanged = true; EditorUtility.SetDirty(script); } #endif } break; case SoundManager.PlayMethod.ContinuousPlayThroughWithRandomDelayInRange: case SoundManager.PlayMethod.OncePlayThroughWithRandomDelayInRange: case SoundManager.PlayMethod.ShufflePlayThroughWithRandomDelayInRange: if(!editable) { EditorGUILayout.LabelField("Min Delay:" + obj.minDelay + " second(s)"); EditorGUILayout.LabelField("Max Delay:" + obj.maxDelay + " second(s)"); } else { minDelayToEdit = obj.minDelay; maxDelayToEdit = obj.maxDelay; #if !(UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2) EditorGUI.BeginChangeCheck(); #endif minDelayToEdit = EditorGUILayout.FloatField("Minimum Delay:",minDelayToEdit); if(minDelayToEdit < 0) minDelayToEdit = 0f; #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 obj.minDelay = minDelayToEdit; #else if(EditorGUI.EndChangeCheck()) { Undo.RecordObjects(new Object[]{script}, "Modify Minimum Delay"); obj.minDelay = minDelayToEdit; EditorUtility.SetDirty(script); } #endif if(maxDelayToEdit < minDelayToEdit) maxDelayToEdit = minDelayToEdit; maxDelayToEdit = EditorGUILayout.FloatField("Maximum Delay:",maxDelayToEdit); if(maxDelayToEdit < 0) maxDelayToEdit = 0f; #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 obj.maxDelay = maxDelayToEdit; #else if(EditorGUI.EndChangeCheck()) { Undo.RecordObjects(new Object[]{script}, "Modify Maximum Delay"); obj.maxDelay = maxDelayToEdit; EditorUtility.SetDirty(script); } #endif #if UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 if(GUI.changed) { if(!guiChanged && listeningForGuiChanges) { guiChanged = true; CheckUndo(); } guiChanged = true; EditorUtility.SetDirty(script); } #endif } break; } EditorGUI.indentLevel--; }
private void ShowSongList(SoundConnection obj, bool editable) { int size = obj.soundsToPlay.Count; EditorGUILayout.LabelField("Sound List:"); EditorGUI.indentLevel++; for (int i = 0; i < size; i++) { EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { if (!editable) { EditorGUILayout.LabelField(obj.soundsToPlay[i].name); } else { if (obj.soundsToPlay[i] == null) { return; } AudioClip newClip = (AudioClip)EditorGUILayout.ObjectField(obj.soundsToPlay[i], typeof(AudioClip), false); if (newClip != null) { obj.soundsToPlay[i] = newClip; } if (GUI.changed) { if (newClip == null) { RemoveSound(obj, i); return; } } bool oldEnabled = GUI.enabled; if (i == 0) { GUI.enabled = false; } if (GUILayout.Button("U", GUILayout.Width(35f))) { SwapSounds(obj, i, i - 1); } GUI.enabled = oldEnabled; if (i == size - 1) { GUI.enabled = false; } if (GUILayout.Button("D", GUILayout.Width(35f))) { SwapSounds(obj, i, i + 1); } GUI.enabled = oldEnabled; GUI.color = Color.red; if (GUILayout.Button("-", GUILayout.Width(20f))) { RemoveSound(obj, i); return; } GUI.color = Color.white; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } if (editable) { EditorGUILayout.BeginHorizontal(); { EditorGUI.indentLevel++; editAddClip = EditorGUILayout.ObjectField("Add A Sound", editAddClip, typeof(AudioClip), false) as AudioClip; GUI.color = softGreen; if (GUILayout.Button("add", GUILayout.Width(40f))) { AddSound(obj, editAddClip); editAddClip = null; } GUI.color = Color.white; EditorGUI.indentLevel--; } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; }
/// <summary> /// Plays the SoundConnection right then, regardless of what you put at the level parameter of the SoundConnection. /// </summary> public static void PlayConnection(SoundConnection sc) { Instance._PlayConnection(sc); }
void OnGUI() { boxStyle = GUI.skin.box; boxStyle.fontStyle = FontStyle.Bold; boxStyle.fontSize = 14; buttonSTyle = GUI.skin.button; buttonSTyle.fontStyle = FontStyle.Bold; labelStyle = GUI.skin.label; labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.fontStyle = FontStyle.Bold; labelStyle.normal.textColor = Color.black; /* TITLE */ GUI.Box(new Rect(16f * unitX, 0f, 16f * unitX, 2f * unitY), "AntiLunchBox\nSoundManagerPro 3.0", boxStyle); /* LOAD SCENES */ GUI.color = buttonColor; if (GUI.Button(new Rect(6f * unitX, 3f * unitY, 8f * unitX, 4f * unitY), "Load Level:\nMusicScene1")) { Application.LoadLevel("MusicScene1"); //LoadLevelAsync also works for UNITY PRO users } if (GUI.Button(new Rect(20f * unitX, 3f * unitY, 8f * unitX, 4f * unitY), "Load Level:\nMusicScene2")) { Application.LoadLevel("MusicScene2"); } if (GUI.Button(new Rect(34f * unitX, 3f * unitY, 8f * unitX, 4f * unitY), "Load Level:\nMusicScene3")) { Application.LoadLevel("MusicScene3"); } GUI.color = Color.white; /* COLUMN 1 */ float yPos = unitY * 8f; float xPos = unitX * 5f; float height = unitY * 3f; float width = unitX * 10f; switch (page) { case 1: // PAGE 1 // Will play sample1, interrupting the current SoundConnection. You can resume a SoundConnection when it's done using another overload below if (GUI.Button(new Rect(xPos, yPos, width, height), "Play Sample1")) { // You can use SoundManager.Load(clipname, customPath) -- Or set SoundManager.resourcesPath and forget the custom path SoundManager.Play(sample1); } // Plays sample2 immediately, no crossfade if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Play Sample2\nImmediately")) { SoundManager.PlayImmediately(sample2); } // Plays sample3, and will call 'ChangeButtonColor' when the song ends. if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Play Sample3 Then\nChange Button Colors\nOn Song End")) { SoundManager.Play(sample3, false, ChangeButtonColor); } // Will play a SoundConnection made in code. Does not save unless you use (AddSoundConnection/ReplaceSoundConnection) if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Play Temporary\nSoundConnection")) { SoundManager.PlayConnection(sc); } // Play a custom SoundConnection not tied to a level if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Play Custom\nSoundConnection\n(\"MyCustom\")")) { SoundManager.PlayConnection("MyCustom"); } /* COLUMN 2 */ yPos = unitY * 8f; xPos = unitX * 19f; // Set to 50% volume if (GUI.Button(new Rect(xPos, yPos, width, height), "Set All Volume 50%")) { SoundManager.SetVolume(.5f); } // Set to 100% volume if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Set All Volume 100%")) { SoundManager.SetVolume(1f); } // Set pitch to .75 if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Set All Pitch 75%")) { SoundManager.SetPitch(.75f); } // Set pitch to 1 if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Set All Pitch 100%")) { SoundManager.SetPitch(1f); } /* COLUMN 3 */ yPos = unitY * 8f; xPos = unitX * 33f; // Crossfade out all music and stop it if (GUI.Button(new Rect(xPos, yPos, width, height), "Stop Music")) { SoundManager.StopMusic(); } // Stop music immediately, no crossfade if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Stop Music\nImmediately")) { SoundManager.StopMusicImmediately(); } // Toggle mute on or off, returns mute status if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Toggle All Mute")) { SoundManager.Mute(); } // Toggle mute of SFX on or off, returns mute status if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Toggle SFX Mute")) { SoundManager.MuteSFX(); } // Toggle mute of music on or off, returns mute status if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Toggle Music Mute")) { SoundManager.MuteMusic(); } break; case 2: // PAGE 2 // Go to next track in playlist if (GUI.Button(new Rect(xPos, yPos, width, height), "Next Track")) { SoundManager.Next(); } // Go to previous track in playlist if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Prev Track")) { SoundManager.Prev(); } // Play sample1 in a loop if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Play Sample1 as\na Looping Track")) { SoundManager.Play(sample1, true); } // Pause all sound if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Pause")) { SoundManager.Pause(); } // Unpause all sound if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "UnPause")) { SoundManager.UnPause(); } /* COLUMN 2 */ yPos = unitY * 8f; xPos = unitX * 19f; // Have SoundManager ignore level loading. So you can set SoundConnections to play when YOU want if (GUI.Button(new Rect(xPos, yPos, width, height), "Set SoundManager to\nIgnore AI")) { SoundManager.SetIgnoreLevelLoad(true); } // Plays sfx, but it will never play more than the set cap amount. The default cap amount is 3. if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Play Capped SFX\nBUTTON SMASH\nTHIS BUTTON!")) { SoundManager.PlayCappedSFX(SoundManager.Load("Explosion1"), "Explosion"); } // Set pitch of only SFX to 1.25 if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Set Pitch of SFX\n125%")) { SoundManager.SetPitchSFX(1.25f); } // Set pitch of only SFX to 1 if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Set Pitch of SFX\n100%")) { SoundManager.SetPitchSFX(1f); } /* COLUMN 3 */ yPos = unitY * 8f; xPos = unitX * 33f; // Remove the SoundConnection from a scene if (GUI.Button(new Rect(xPos, yPos, width, height), "Remove SoundConnection\nin MusicScene1")) { SoundManager.RemoveSoundConnectionForLevel("MusicScene1"); } // Add a SoundConnection to a scene, or if it exists already, replace it. if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Add/Replace\nSoundConnection\nin MusicScene1")) { SoundConnection replacement = SoundManager.CreateSoundConnection("MusicScene1", SoundManager.PlayMethod.ContinuousPlayThrough, sample4, sample2, sample3, sample1); SoundManager.ReplaceSoundConnection(replacement); } // Add a CUSTOM SoundConnection to a scene, or if it exists already, replace it. if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Add/Replace\nCustom SoundConnection\n(\"NewCustom\")")) { SoundConnection newCustom = SoundManager.CreateSoundConnection("NewCustom", SoundManager.PlayMethod.ContinuousPlayThrough, sample4, sample2, sample3, sample1); SoundManager.ReplaceSoundConnection(newCustom); } // Plays a random SFX from a group if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Play Random SFX\nfrom MyGroup")) { SoundManager.PlaySFX(SoundManager.LoadFromGroup("MyGroup")); } // Change the duration of music crossfades if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Change the Crossfade\nDuration to 1s")) { SoundManager.SetCrossDuration(1f); } break; case 3: // PAGE 3 // Cross in a SFX. Crossfade, crossout are all available as well if (GUI.Button(new Rect(xPos, yPos, width, height), "Cross in a SFX")) { SoundManager.CrossIn(1f, SoundManager.PlaySFX(SoundManager.Load("Eruption1"))); } // Play a SFX while ducking all other sound if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Use ducking for\nFlash Bang effect")) { SoundManager.PlaySFX(SoundManager.Load("Flashbang1"), 1f, 1f, Vector3.zero, false, 0f, null, SoundDuckingSetting.DuckAll, .1f); } // Play a SFX while ducking all other sound and while pitch if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Use ducking for\nSlo Mo effect")) { SoundManager.PlaySFX(SoundManager.Load("Pentakill1"), 1f, .65f, Vector3.zero, false, 0f, null, SoundDuckingSetting.DuckAll, .1f, .5f); } // Run function to debug output at end of SFX play if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Run function that\ndebugs at end\nof playing SFX")) { SoundManager.PlaySFX(SoundManager.Load("Explosion1"), 1f, 1f, Vector3.zero, false, 0f, RunThisOnEnd); } // Play SFX with delay if (GUI.Button(new Rect(xPos, yPos += (unitY * 4f), width, height), "Play SFX after\n1 second")) { SoundManager.PlaySFX(SoundManager.Load("Explosion1"), 1f, 1f, Vector3.zero, false, 1f); } break; default: break; } /* FOOTER */ // Spawn the explosion particle effect and play the sound effect in 2 different ways (there are 6 more overloads) if (GUI.Button(new Rect(20f * unitX, 24f * unitY + Mathf.PingPong(Time.time * 24f, unitY), 8f * unitX, 5f * unitY), AntiLunchBoxLogo, labelStyle)) { GameObject newExplosion = GameObject.Instantiate(explosionPrefab, Camera.main.transform.position + (5f * Camera.main.transform.forward), Quaternion.identity) as GameObject; if (Random.Range(0, 2) == 1) { // This will play the SFX from the Stored SFXs on SoundManager, in the pooling system. SoundManager.PlaySFX(SoundManager.Load("Explosion1")); } else { // This will play the SFX on the gameobject--if it doesn't have an audiosource, it'll add it for you. SoundManager.PlaySFX(newExplosion, SoundManager.Load("Explosion1")); } //If you want to make sure that audiosource is 2D, use this: //SoundManagerTools.make2D( ref SoundManager.PlaySFX(newExplosion, SoundManager.Load("Explosion1"))); //OR 3d //SoundManagerTools.make3D( ref SoundManager.PlaySFX(newExplosion, SoundManager.Load("Explosion1"))); } GUI.Label(new Rect(20f * unitX, 24f * unitY + Mathf.PingPong(Time.time * 24f, unitY), 8f * unitX, 5f * unitY), "Click Me!", labelStyle); if (!CanGoNext()) { GUI.enabled = false; } if (GUI.Button(new Rect(Screen.width - 75f, 0f, 75f, 50f), "Next\nPage")) { page++; } GUI.enabled = true; if (!CanGoPrev()) { GUI.enabled = false; } if (GUI.Button(new Rect(0f, 0f, 75f, 50f), "Prev\nPage")) { page--; } GUI.enabled = true; }
// Use this for initialization protected override void Start() { base.Start(); m_maxSelection = GetListOfActiveButtons(); m_DelayManager = GetComponent<DelayManager>(); m_DelayManager.Reset(); m_myConnection = SoundManager.GetCurrentSoundConnection(); m_RoundMenu.SetActive(false); m_MatchMenu.SetActive(false); m_RoundPanel.SetActive(false); }