public SoundConnection(string lvl, SoundManager.PlayMethod method, params AudioClip[] audioList) { level = lvl; isCustomLevel = false; playMethod = method; switch(playMethod) { case SoundManager.PlayMethod.ContinuousPlayThrough: case SoundManager.PlayMethod.OncePlayThrough: case SoundManager.PlayMethod.ShufflePlayThrough: break; default: Debug.LogWarning("No delay was set in the constructor so there will be none."); break; } minDelay = 0f; maxDelay = 0f; delay = 0f; soundsToPlay = new List<AudioClip>(); baseVolumes = new List<float>(); foreach(AudioClip audio in audioList) { if(!soundsToPlay.Contains(audio)) { soundsToPlay.Add(audio); baseVolumes.Add(1f); } } }
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> /// Initializes a new instance of the <see cref="SoundConnection"/> class. /// </summary> /// <param name='lvl'> /// Level name. /// </param> /// <param name='method'> /// PlayMethod. /// </param> /// <param name='audioList'> /// Audio list. /// </param> public SoundConnection(string lvl, SoundManager.PlayMethod method, params AudioClip[] audioList) { level = lvl; isCustomLevel = false; playMethod = method; switch (playMethod) { case SoundManager.PlayMethod.ContinuousPlayThrough: case SoundManager.PlayMethod.OncePlayThrough: case SoundManager.PlayMethod.ShufflePlayThrough: break; default: //Debug.LogWarning("No delay was set in the constructor so there will be none."); break; } minDelay = 0f; maxDelay = 0f; delay = 0f; soundsToPlay = new List <AudioClip>(); baseVolumes = new List <float>(); foreach (AudioClip audio in audioList) { if (!soundsToPlay.Contains(audio)) { soundsToPlay.Add(audio); baseVolumes.Add(1f); } } }
/// <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); }
/// <summary> /// 创建音乐 /// </summary> /// <returns></returns> protected SoundConnection CreateConnection(List <string> musics, SoundManager.PlayMethod type = SoundManager.PlayMethod.ContinuousPlayThroughWithRandomDelayInRange) { var audios = BaseGlobal.GRMgr.Music.Get(musics); if (audios == null || audios.Length == 0) { return(null); } return(SoundManager.CreateSoundConnection("", type, audios)); }
public override void Reset() { levelName = new FsmString { Value = Application.loadedLevelName }; soundConnection = null; playMethod = SoundManager.PlayMethod.ContinuousPlayThrough; clip1 = clip2 = clip3 = clip4 = clip5 = clip6 = clip7 = clip8 = clip9 = clip10 = null; delay = new FsmFloat { UseVariable = true }; minDelay = new FsmFloat { UseVariable = true }; maxDelay = new FsmFloat { UseVariable = true }; }
string GetPlayMethodDescription(SoundManager.PlayMethod method) { string desc = ""; switch (method) { case SoundManager.PlayMethod.ContinuousPlayThrough: desc = "Repeat All In Order"; break; case SoundManager.PlayMethod.OncePlayThrough: desc = "Play All In Order Once"; break; case SoundManager.PlayMethod.ShufflePlayThrough: desc = "Repeat All Shuffled"; break; case SoundManager.PlayMethod.ContinuousPlayThroughWithDelay: desc = "Repeat All In Order With Delay Between Songs"; break; case SoundManager.PlayMethod.OncePlayThroughWithDelay: desc = "Play All In Order Once With Delay Between Songs"; break; case SoundManager.PlayMethod.ShufflePlayThroughWithDelay: desc = "Repeat All Shuggled With Delay Between Songs"; break; case SoundManager.PlayMethod.ContinuousPlayThroughWithRandomDelayInRange: desc = "Repeat All In Order With Delay Between Songs Within A Range"; break; case SoundManager.PlayMethod.OncePlayThroughWithRandomDelayInRange: desc = "Play All In Order Once With Delay Between Songs Within A Range"; break; case SoundManager.PlayMethod.ShufflePlayThroughWithRandomDelayInRange: desc = "Repeat All Shuffled With Delay Between Songs Within A Range"; break; default: break; } return(desc); }
public SoundConnection(string lvl, SoundManager.PlayMethod method, float minDelayPlay, float maxDelayPlay, params AudioClip[] audioList) { level = lvl; isCustomLevel = false; playMethod = method; minDelay = minDelayPlay; maxDelay = maxDelayPlay; delay = (maxDelayPlay+minDelayPlay) / 2f; soundsToPlay = new List<AudioClip>(); foreach(AudioClip audio in audioList) { if(!soundsToPlay.Contains(audio)) { soundsToPlay.Add(audio); } } }
public SoundConnection(string lvl, SoundManager.PlayMethod method, float minDelayPlay, float maxDelayPlay, params AudioClip[] audioList) { level = lvl; isCustomLevel = false; playMethod = method; minDelay = minDelayPlay; maxDelay = maxDelayPlay; delay = (maxDelayPlay + minDelayPlay) / 2f; soundsToPlay = new List <AudioClip>(); foreach (AudioClip audio in audioList) { if (!soundsToPlay.Contains(audio)) { soundsToPlay.Add(audio); } } }
private bool ShowPlayMethodParameters(SoundManager.PlayMethod method) { bool canMoveOn = true; 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: canMoveOn = false; delayToAdd = EditorGUILayout.FloatField("Delay:", delayToAdd); if (delayToAdd < 0) { delayToAdd = 0f; } canMoveOn = true; break; case SoundManager.PlayMethod.ContinuousPlayThroughWithRandomDelayInRange: case SoundManager.PlayMethod.OncePlayThroughWithRandomDelayInRange: case SoundManager.PlayMethod.ShufflePlayThroughWithRandomDelayInRange: canMoveOn = false; minDelayToAdd = EditorGUILayout.FloatField("Minimum Delay:", minDelayToAdd); if (minDelayToAdd < 0) { minDelayToAdd = 0f; } if (maxDelayToAdd < minDelayToAdd) { maxDelayToAdd = minDelayToAdd; } maxDelayToAdd = EditorGUILayout.FloatField("Maximum Delay:", maxDelayToAdd); if (maxDelayToAdd < 0) { maxDelayToAdd = 0f; } canMoveOn = true; break; } return(canMoveOn); }
/*Ties the level name to a list of AudioClips. It defaults to continuous play through with no delay between clips.*/ public void Initialize(string lvl, params AudioClip[] audioList) { level = lvl; isCustomLevel = false; playMethod = SoundManager.PlayMethod.ContinuousPlayThrough; minDelay = 0f; maxDelay = 0f; delay = 0f; soundsToPlay = new List<AudioClip>(); foreach(AudioClip audio in audioList) { if(!soundsToPlay.Contains(audio)) { soundsToPlay.Add(audio); } } }
/*Ties the level name to a list of AudioClips. It defaults to continuous play through with no delay between clips.*/ public SoundConnection(string lvl, params AudioClip[] audioList) { level = lvl; isCustomLevel = false; playMethod = SoundManager.PlayMethod.ContinuousPlayThrough; minDelay = 0f; maxDelay = 0f; delay = 0f; soundsToPlay = new List <AudioClip>(); foreach (AudioClip audio in audioList) { if (!soundsToPlay.Contains(audio)) { soundsToPlay.Add(audio); } } }
public void Initialize(string lvl, SoundManager.PlayMethod method, float delayPlay, params AudioClip[] audioList) { level = lvl; isCustomLevel = false; playMethod = method; minDelay = 0f; maxDelay = delayPlay; delay = delayPlay; soundsToPlay = new List<AudioClip>(); foreach(AudioClip audio in audioList) { if(!soundsToPlay.Contains(audio)) { soundsToPlay.Add(audio); } } }
public SoundConnection(string lvl, SoundManager.PlayMethod method, float delayPlay, params AudioClip[] audioList) { level = lvl; isCustomLevel = false; playMethod = method; minDelay = 0f; maxDelay = delayPlay; delay = delayPlay; soundsToPlay = new List<AudioClip>(); baseVolumes = new List<float>(); foreach(AudioClip audio in audioList) { if(!soundsToPlay.Contains(audio)) { soundsToPlay.Add(audio); baseVolumes.Add(1f); } } }
/// <summary> /// Initializes a new instance of the <see cref="SoundConnection"/> class. Sets the exact delay for appropriate play methods. /// </summary> /// <param name='lvl'> /// Level name. /// </param> /// <param name='method'> /// PlayMethod. /// </param> /// <param name='delayPlay'> /// Delay. /// </param> /// <param name='audioList'> /// Audio list. /// </param> public SoundConnection(string lvl, SoundManager.PlayMethod method, float delayPlay, params AudioClip[] audioList) { level = lvl; isCustomLevel = false; playMethod = method; minDelay = 0f; maxDelay = delayPlay; delay = delayPlay; soundsToPlay = new List <AudioClip>(); baseVolumes = new List <float>(); foreach (AudioClip audio in audioList) { if (!soundsToPlay.Contains(audio)) { soundsToPlay.Add(audio); baseVolumes.Add(1f); } } }
private bool ShowRequiredSoundConnectionInfo() { bool canMoveOn = true, forceRepaint = false; if (canMoveOn) { canMoveOn = false; string[] availableNames = GetAvailableLevelNamesForAddition(); if (availableNames.Length == 1) { EditorGUILayout.LabelField("All enabled scenes have SoundConnections already."); } if (levelIndex >= availableNames.Length) { levelIndex = availableNames.Length - 1; } levelIndex = EditorGUILayout.Popup("Choose Level:", levelIndex, availableNames, EditorStyles.popup); if (levelIndex == availableNames.Length - 1) //must be custom { if (!isCustom) { if (levelToAdd != defaultName) { levelToAdd = defaultName; forceRepaint = true; GUIUtility.keyboardControl = 0; } } isCustom = true; bool isValidName = true, isEmptyName = false; if (string.IsNullOrEmpty(levelToAdd) || levelToAdd == defaultName) { isEmptyName = true; } if (isEmptyName || IsStringSceneName(levelToAdd) || IsStringAlreadyTaken(levelToAdd)) { isValidName = false; } if (isValidName) { GUI.color = Color.green; } else if (!isEmptyName) { GUI.color = Color.red; } EditorGUILayout.BeginHorizontal(); { levelToAdd = EditorGUILayout.TextField("Custom Level Name:", levelToAdd, GUILayout.MinWidth(100), GUILayout.ExpandWidth(true)); if (isValidName) { EditorGUILayout.LabelField("OK", GUILayout.Width(35)); } else if (!isEmptyName) { EditorGUILayout.LabelField("BAD", GUILayout.Width(35)); } canMoveOn = isValidName; } EditorGUILayout.EndHorizontal(); GUI.color = Color.white; } else { if (isCustom) { forceRepaint = repaintNextFrame = true; GUIUtility.keyboardControl = 0; } isCustom = false; levelToAdd = availableNames[levelIndex]; canMoveOn = true; } if (canMoveOn) { canMoveOn = false; playMethodToAdd = (SoundManager.PlayMethod)EditorGUILayout.EnumPopup("Play Method:", playMethodToAdd, EditorStyles.popup); canMoveOn = ShowPlayMethodParameters(playMethodToAdd); } } if (forceRepaint) { SceneView.RepaintAll(); } else if (repaintNextFrame) { SceneView.RepaintAll(); repaintNextFrame = false; } return(canMoveOn); }
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--; }
/// <summary> /// 创建音乐 /// </summary> /// <returns></returns> protected SoundConnection CreateConnection(List <string> musics, SoundManager.PlayMethod type = SoundManager.PlayMethod.ContinuousPlayThroughWithRandomDelayInRange) { return(SoundManager.CreateSoundConnection("", type, SelfBaseGlobal.GRMgr.GetMusics(musics))); }
private bool ShowRequiredSoundConnectionInfo() { bool canMoveOn = true, forceRepaint = false; if(canMoveOn) { canMoveOn = false; string[] availableNames = GetAvailableLevelNamesForAddition(); if(availableNames.Length == 1) { EditorGUILayout.LabelField("All enabled scenes have SoundConnections already."); } if(levelIndex >= availableNames.Length) levelIndex = availableNames.Length-1; levelIndex = EditorGUILayout.Popup("Choose Level:", levelIndex, availableNames, EditorStyles.popup); if(levelIndex == availableNames.Length-1) //must be custom { if(!isCustom) { if(levelToAdd != defaultName) { levelToAdd = defaultName; forceRepaint = true; GUIUtility.keyboardControl = 0; } } isCustom = true; bool isValidName = true, isEmptyName = false; if(string.IsNullOrEmpty(levelToAdd) || levelToAdd == defaultName) isEmptyName = true; if(isEmptyName || IsStringSceneName(levelToAdd) || IsStringAlreadyTaken(levelToAdd)) isValidName = false; if(isValidName) GUI.color = Color.green; else if(!isEmptyName) GUI.color = Color.red; EditorGUILayout.BeginHorizontal(); { levelToAdd = EditorGUILayout.TextField("Custom Level Name:", levelToAdd, GUILayout.MinWidth(100), GUILayout.ExpandWidth(true)); if(isValidName) EditorGUILayout.LabelField("OK", GUILayout.Width(35)); else if(!isEmptyName) EditorGUILayout.LabelField("BAD", GUILayout.Width(35)); canMoveOn = isValidName; } EditorGUILayout.EndHorizontal(); GUI.color = Color.white; } else { if(isCustom) { forceRepaint = repaintNextFrame = true; GUIUtility.keyboardControl = 0; } isCustom = false; levelToAdd = availableNames[levelIndex]; canMoveOn = true; } if(canMoveOn) { canMoveOn = false; playMethodToAdd = (SoundManager.PlayMethod)EditorGUILayout.EnumPopup("Play Method:", playMethodToAdd, EditorStyles.popup); canMoveOn = ShowPlayMethodParameters(playMethodToAdd); } } if(forceRepaint) SceneView.RepaintAll(); else if(repaintNextFrame) { SceneView.RepaintAll(); repaintNextFrame = false; } return canMoveOn; }