private void DrawBehaviorActions(UIAction actions, SerializedProperty actionsProperty, AnimBool expanded, string unityEventDisplayPath) { float alpha = GUI.color.a; if (DGUI.FadeOut.Begin(expanded, false)) { SerializedProperty soundDataProperty = GetProperty(PropertyName.SoundData, actionsProperty); SerializedProperty effectProperty = GetProperty(PropertyName.Effect, actionsProperty); SerializedProperty animatorEventsProperty = GetProperty(PropertyName.AnimatorEvents, actionsProperty); SerializedProperty gameEventsProperty = GetProperty(PropertyName.GameEvents, actionsProperty); SerializedProperty unityEventProperty = GetProperty(PropertyName.Event, actionsProperty); if (!expanded.target) { m_soundDataExpanded.target = false; m_effectExpanded.target = false; m_animatorEventsExpanded.target = false; m_gameEventsExpanded.target = false; m_unityEventsExpanded.target = false; } else { if (!m_soundDataExpanded.target && !m_effectExpanded.target && !m_animatorEventsExpanded.target && !m_gameEventsExpanded.target && !m_unityEventsExpanded.target) { m_soundDataExpanded.target = true; } } GUILayout.BeginHorizontal(); { if (DGUI.Doozy.DrawSubSectionButtonLeft(m_soundDataExpanded.target, UILabels.Sound, ComponentColorName, DGUI.IconGroup.GetIcon( actions.HasSound, DGUI.IconGroup.IconSize, DGUI.Icon.Sound, DGUI.Icon.Sound, ComponentColorName, DGUI.Colors.DisabledIconColorName))) { m_soundDataExpanded.target = true; m_effectExpanded.value = false; m_animatorEventsExpanded.value = false; m_gameEventsExpanded.value = false; m_unityEventsExpanded.value = false; } GUILayout.Space(DGUI.Properties.Space()); if (DGUI.Doozy.DrawSubSectionButtonMiddle(m_effectExpanded.target, UILabels.Effect, ComponentColorName, DGUI.IconGroup.GetIcon( actions.HasEffect, DGUI.IconGroup.IconSize, DGUI.Icon.Effect, DGUI.Icon.Effect, ComponentColorName, DGUI.Colors.DisabledIconColorName))) { m_soundDataExpanded.value = false; m_effectExpanded.target = true; m_animatorEventsExpanded.value = false; m_gameEventsExpanded.value = false; m_unityEventsExpanded.value = false; SoundyAudioPlayer.StopAllPlayers(); } GUILayout.Space(DGUI.Properties.Space()); if (DGUI.Doozy.DrawSubSectionButtonMiddle(m_animatorEventsExpanded.target, UILabels.Animators, ComponentColorName, DGUI.IconGroup.GetIconWithCounter( actions.HasAnimatorEvents, actions.AnimatorEventsCount, DGUI.IconGroup.IconSize, DGUI.Icon.Animator, DGUI.Icon.Animator, ComponentColorName, DGUI.Colors.DisabledIconColorName))) { m_soundDataExpanded.value = false; m_effectExpanded.value = false; m_animatorEventsExpanded.target = true; m_gameEventsExpanded.value = false; m_unityEventsExpanded.value = false; SoundyAudioPlayer.StopAllPlayers(); } GUILayout.Space(DGUI.Properties.Space()); if (DGUI.Doozy.DrawSubSectionButtonMiddle(m_gameEventsExpanded.target, UILabels.GameEvents, ComponentColorName, DGUI.IconGroup.GetIconWithCounter( actions.HasGameEvents, actions.GameEventsCount, DGUI.IconGroup.IconSize, DGUI.Icon.GameEvent, DGUI.Icon.GameEvent, ComponentColorName, DGUI.Colors.DisabledIconColorName))) { m_soundDataExpanded.value = false; m_effectExpanded.value = false; m_animatorEventsExpanded.value = false; m_gameEventsExpanded.target = true; m_unityEventsExpanded.value = false; SoundyAudioPlayer.StopAllPlayers(); } GUILayout.Space(DGUI.Properties.Space()); if (DGUI.Doozy.DrawSubSectionButtonRight(m_unityEventsExpanded.target, UILabels.UnityEvents, ComponentColorName, DGUI.IconGroup.GetIconWithCounter( actions.HasUnityEvent, actions.UnityEventListenerCount, DGUI.IconGroup.IconSize, DGUI.Icon.UnityEvent, DGUI.Icon.UnityEvent, ComponentColorName, DGUI.Colors.DisabledIconColorName))) { m_soundDataExpanded.value = false; m_effectExpanded.value = false; m_animatorEventsExpanded.value = false; m_gameEventsExpanded.value = false; m_unityEventsExpanded.target = true; SoundyAudioPlayer.StopAllPlayers(); } } GUILayout.EndHorizontal(); //ADD EXTRA SPACE if needed if (m_animatorEventsExpanded.target || m_effectExpanded.target || m_gameEventsExpanded.target) { GUILayout.Space(DGUI.Properties.Space()); } //DRAW SOUND if (m_soundDataExpanded.target) { DGUI.Property.DrawWithFade(soundDataProperty, m_soundDataExpanded); } //DRAW EFFECT if (m_effectExpanded.target) { DGUI.Doozy.DrawUIEffect(Target.gameObject, actions.Effect, GetProperty(PropertyName.ParticleSystem, effectProperty), GetProperty(PropertyName.Behavior, effectProperty), GetProperty(PropertyName.StopBehavior, effectProperty), GetProperty(PropertyName.AutoSort, effectProperty), GetProperty(PropertyName.SortingSteps, effectProperty), GetProperty(PropertyName.CustomSortingLayer, effectProperty), GetProperty(PropertyName.CustomSortingOrder, effectProperty), m_effectExpanded, ComponentColorName); } //DRAW ANIMATOR EVENTS if (m_animatorEventsExpanded.target) { DGUI.List.DrawWithFade(animatorEventsProperty, m_animatorEventsExpanded, ComponentColorName, UILabels.ListIsEmpty); } //DRAW GAME EVENTS if (m_gameEventsExpanded.target) { DGUI.List.DrawWithFade(gameEventsProperty, m_gameEventsExpanded, ComponentColorName, UILabels.ListIsEmpty, 1); } //DRAW EVENTS (UnityEvent) if (m_unityEventsExpanded.target) { DGUI.Property.UnityEventWithFade(unityEventProperty, m_unityEventsExpanded, unityEventDisplayPath + ".Event", ComponentColorName, actions.UnityEventListenerCount); } } DGUI.FadeOut.End(expanded, true, alpha); }
private void DrawActions() { DGUI.Doozy.DrawTitleWithIconAndBackground(Styles.GetStyle(Styles.StyleName.IconAction), UILabels.Actions, Size.L, DGUI.Properties.SingleLineHeight + DGUI.Properties.Space(2), ComponentColorName, ComponentColorName); GUILayout.Space(DGUI.Properties.Space()); SerializedProperty soundDataProperty = GetProperty(PropertyName.SoundData, m_actions); SerializedProperty effectProperty = GetProperty(PropertyName.Effect, m_actions); SerializedProperty animatorEventsProperty = GetProperty(PropertyName.AnimatorEvents, m_actions); SerializedProperty gameEventsProperty = GetProperty(PropertyName.GameEvents, m_actions); SerializedProperty unityEventProperty = GetProperty(PropertyName.Event, m_actions); if (!m_soundDataExpanded.target && !m_effectExpanded.target && !m_animatorEventsExpanded.target && !m_gameEventsExpanded.target && !m_unityEventsExpanded.target) { m_soundDataExpanded.target = true; } GUILayout.BeginHorizontal(); { if (DGUI.Doozy.DrawSubSectionButtonLeft(m_soundDataExpanded.target, UILabels.Sound, ComponentColorName, DGUI.IconGroup.GetIcon( Target.Actions.HasSound, DGUI.IconGroup.IconSize, DGUI.Icon.Sound, DGUI.Icon.Sound, ComponentColorName, DGUI.Colors.DisabledIconColorName))) { m_soundDataExpanded.target = true; m_effectExpanded.value = false; m_animatorEventsExpanded.value = false; m_gameEventsExpanded.value = false; m_unityEventsExpanded.value = false; } GUILayout.Space(DGUI.Properties.Space()); if (DGUI.Doozy.DrawSubSectionButtonMiddle(m_effectExpanded.target, UILabels.Effect, ComponentColorName, DGUI.IconGroup.GetIcon( Target.Actions.HasEffect, DGUI.IconGroup.IconSize, DGUI.Icon.Effect, DGUI.Icon.Effect, ComponentColorName, DGUI.Colors.DisabledIconColorName))) { m_soundDataExpanded.value = false; m_effectExpanded.target = true; m_animatorEventsExpanded.value = false; m_gameEventsExpanded.value = false; m_unityEventsExpanded.value = false; SoundyAudioPlayer.StopAllPlayers(); } GUILayout.Space(DGUI.Properties.Space()); if (DGUI.Doozy.DrawSubSectionButtonMiddle(m_animatorEventsExpanded.target, UILabels.Animators, ComponentColorName, DGUI.IconGroup.GetIconWithCounter( Target.Actions.HasAnimatorEvents, Target.Actions.AnimatorEventsCount, DGUI.IconGroup.IconSize, DGUI.Icon.Animator, DGUI.Icon.Animator, ComponentColorName, DGUI.Colors.DisabledIconColorName))) { m_soundDataExpanded.value = false; m_effectExpanded.value = false; m_animatorEventsExpanded.target = true; m_gameEventsExpanded.value = false; m_unityEventsExpanded.value = false; SoundyAudioPlayer.StopAllPlayers(); } GUILayout.Space(DGUI.Properties.Space()); if (DGUI.Doozy.DrawSubSectionButtonMiddle(m_gameEventsExpanded.target, UILabels.GameEvents, ComponentColorName, DGUI.IconGroup.GetIconWithCounter( Target.Actions.HasGameEvents, Target.Actions.GameEventsCount, DGUI.IconGroup.IconSize, DGUI.Icon.GameEvent, DGUI.Icon.GameEvent, ComponentColorName, DGUI.Colors.DisabledIconColorName))) { m_soundDataExpanded.value = false; m_effectExpanded.value = false; m_animatorEventsExpanded.value = false; m_gameEventsExpanded.target = true; m_unityEventsExpanded.value = false; SoundyAudioPlayer.StopAllPlayers(); } GUILayout.Space(DGUI.Properties.Space()); if (DGUI.Doozy.DrawSubSectionButtonRight(m_unityEventsExpanded.target, UILabels.UnityEvents, ComponentColorName, DGUI.IconGroup.GetIconWithCounter( Target.Actions.HasUnityEvent, Target.Actions.UnityEventListenerCount, DGUI.IconGroup.IconSize, DGUI.Icon.UnityEvent, DGUI.Icon.UnityEvent, ComponentColorName, DGUI.Colors.DisabledIconColorName))) { m_soundDataExpanded.value = false; m_effectExpanded.value = false; m_animatorEventsExpanded.value = false; m_gameEventsExpanded.value = false; m_unityEventsExpanded.target = true; SoundyAudioPlayer.StopAllPlayers(); } } GUILayout.EndHorizontal(); //ADD EXTRA SPACE if needed if (m_animatorEventsExpanded.target || m_effectExpanded.target || m_gameEventsExpanded.target) { GUILayout.Space(DGUI.Properties.Space()); } //DRAW SOUND if (m_soundDataExpanded.target) { DGUI.Property.DrawWithFade(soundDataProperty, m_soundDataExpanded); } //DRAW EFFECT if (m_effectExpanded.target) { DGUI.Doozy.DrawUIEffect(Target.gameObject, Target.Actions.Effect, GetProperty(PropertyName.ParticleSystem, effectProperty), GetProperty(PropertyName.Behavior, effectProperty), GetProperty(PropertyName.StopBehavior, effectProperty), GetProperty(PropertyName.AutoSort, effectProperty), GetProperty(PropertyName.SortingSteps, effectProperty), GetProperty(PropertyName.CustomSortingLayer, effectProperty), GetProperty(PropertyName.CustomSortingOrder, effectProperty), m_effectExpanded, ComponentColorName); } //DRAW ANIMATOR EVENTS if (m_animatorEventsExpanded.target) { DGUI.List.DrawWithFade(animatorEventsProperty, m_animatorEventsExpanded, ComponentColorName, UILabels.ListIsEmpty); } //DRAW GAME EVENTS if (m_gameEventsExpanded.target) { DGUI.List.DrawWithFade(gameEventsProperty, m_gameEventsExpanded, ComponentColorName, UILabels.ListIsEmpty, 1); } //DRAW EVENTS (UnityEvent) if (m_unityEventsExpanded.target) { DGUI.Property.UnityEventWithFade(unityEventProperty, m_unityEventsExpanded, "Actions.Event", ComponentColorName, Target.Actions.UnityEventListenerCount); } }
private void DrawBehavior(string behaviorName, SceneLoadBehavior behavior, SerializedProperty behaviorProperty, AnimBool behaviorExpanded) { SerializedProperty loadSceneProperty = GetProperty(PropertyName.OnLoadScene, behaviorProperty); SerializedProperty sceneLoadedProperty = GetProperty(PropertyName.OnSceneLoaded, behaviorProperty); AnimBool loadSceneExpanded = GetAnimBool(loadSceneProperty.propertyPath, loadSceneProperty.isExpanded); AnimBool sceneLoadedExpanded = GetAnimBool(sceneLoadedProperty.propertyPath, sceneLoadedProperty.isExpanded); if (DGUI.Bar.Draw(behaviorName, NORMAL_BAR_SIZE, DGUI.Bar.Caret.CaretType.Caret, ComponentColorName, behaviorExpanded)) { SoundyAudioPlayer.StopAllPlayers(); } GUILayout.Space(-NormalBarHeight); DrawBehaviorIcons(behavior, behaviorExpanded); if (DGUI.FadeOut.Begin(behaviorExpanded, false)) { GUILayout.BeginVertical(); { GUILayout.Space(DGUI.Properties.Space() * behaviorExpanded.faded); GUILayout.BeginHorizontal(); { if (DGUI.Doozy.DrawSectionButtonLeft(loadSceneExpanded.target, UILabels.OnLoadScene + " (0%)", DGUI.Icon.ActionStart, ComponentColorName, DGUI.Doozy.GetActionsIcons(behavior.OnLoadScene, m_behaviorActionsIconsDatabase, ComponentColorName))) { loadSceneExpanded.target = true; sceneLoadedExpanded.value = false; SoundyAudioPlayer.StopAllPlayers(); } GUILayout.Space(DGUI.Properties.Space()); if (DGUI.Doozy.DrawSectionButtonRight(sceneLoadedExpanded.target, UILabels.OnSceneLoaded + " (90%)", DGUI.Icon.ActionFinished, ComponentColorName, DGUI.Doozy.GetActionsIcons(behavior.OnSceneLoaded, m_behaviorActionsIconsDatabase, ComponentColorName))) { loadSceneExpanded.value = false; sceneLoadedExpanded.target = true; SoundyAudioPlayer.StopAllPlayers(); } } GUILayout.EndHorizontal(); if (behaviorExpanded.target && !loadSceneExpanded.target && !sceneLoadedExpanded.target) { loadSceneExpanded.value = true; } loadSceneProperty.isExpanded = loadSceneExpanded.target; sceneLoadedProperty.isExpanded = sceneLoadedExpanded.target; GUILayout.Space(DGUI.Properties.Space(3) * behaviorExpanded.faded); DrawBehaviorActions(behavior.OnLoadScene, loadSceneProperty, loadSceneExpanded, "OnLoadScene"); DrawBehaviorActions(behavior.OnSceneLoaded, sceneLoadedProperty, sceneLoadedExpanded, "OnSceneLoaded"); } GUILayout.EndVertical(); } DGUI.FadeOut.End(behaviorExpanded); behaviorProperty.isExpanded = behaviorExpanded.target; }
protected override void OnDisable() { base.OnDisable(); SoundyAudioPlayer.StopAllPlayers(); }
private void DrawViewSoundySoundDatabases(AnimBool searchEnabled) { bool foundNullReference = false; foreach (SoundDatabase soundDatabase in SoundyDatabase.SoundDatabases) { if (soundDatabase == null) { foundNullReference = true; break; } AnimBool soundDatabaseAnimBool = GetSoundDatabaseAnimBool(soundDatabase); AnimBool renameSoundDatabaseAnimBool = GetAnimBool(RENAME_SOUND_DATABASE); bool isGeneralSoundDatabase = soundDatabase.DatabaseName.Equals(SoundyManager.GENERAL); bool soundDatabaseContainsSearchedSound = false; bool renamingThisDatabase = !searchEnabled.target && m_soundDatabaseBeingRenamed == soundDatabase; bool databaseHasIssues = soundDatabase.HasSoundsWithMissingAudioClips; //database issues check ColorName viewColorName = CurrentViewColorName; ColorName mixerColorName = soundDatabase.OutputAudioMixerGroup != null ? viewColorName : DGUI.Colors.DisabledTextColorName; GUILayout.BeginHorizontal(); { DrawViewHorizontalPadding(); GUILayout.BeginVertical(); { GUILayout.BeginHorizontal(); { bool enabledState = GUI.enabled; GUI.enabled = !(renameSoundDatabaseAnimBool.target && renamingThisDatabase) && !searchEnabled.target; //do not allow the dev to use this button if THIS database is being renamed or a search is happening { GUILayout.BeginVertical(GUILayout.Height(BarHeight)); { if (DGUI.Bar.Draw(soundDatabase.DatabaseName, BAR_SIZE, DGUI.Bar.Caret.CaretType.Caret, viewColorName, soundDatabaseAnimBool)) //database BAR { if (Selection.activeObject != null && Selection.activeObject is SoundGroupData) { Selection.activeObject = null; } } GUILayout.Space(-BarHeight - DGUI.Properties.Space()); if (soundDatabase.OutputAudioMixerGroup == null) { DGUI.Colors.SetDisabledGUIColorAlpha(); } float barIconSize = BarHeight * 0.6f; SoundDatabase database = soundDatabase; DGUI.Line.Draw(false, () => { GUILayout.FlexibleSpace(); DGUI.Icon.Draw(Styles.GetStyle(Styles.StyleName.IconAudioMixerGroup), barIconSize, BarHeight, mixerColorName); //mixer icon if (database.OutputAudioMixerGroup != null) { GUILayout.Space(DGUI.Properties.Space(2)); DGUI.Label.Draw(database.OutputAudioMixerGroup.name + " (" + database.OutputAudioMixerGroup.audioMixer.name + ")", Size.S, mixerColorName, BarHeight); //mixer label } if (databaseHasIssues) { GUILayout.Space(DGUI.Properties.Space(4)); DGUI.Icon.Draw(Styles.GetStyle(Styles.StyleName.IconError), barIconSize, BarHeight, Color.red); } GUILayout.Space(DGUI.Properties.Space(2)); }); GUI.color = InitialGUIColor; } GUILayout.EndVertical(); } GUI.enabled = enabledState; if (!isGeneralSoundDatabase) { if (!searchEnabled.target && soundDatabaseAnimBool.faded > 0.05f && renameSoundDatabaseAnimBool.faded < 0.5f) { DGUI.AlphaGroup.Begin(soundDatabaseAnimBool.faded * (1 - renameSoundDatabaseAnimBool.faded)); GUILayout.Space(DGUI.Properties.Space() * soundDatabaseAnimBool.faded * (1 - renameSoundDatabaseAnimBool.faded)); if (DGUI.Button.Draw(DGUI.Properties.Labels.Rename, Size.S, TextAlign.Center, viewColorName, true, BarHeight, 80 * soundDatabaseAnimBool.faded * (1 - renameSoundDatabaseAnimBool.faded)) || renamingThisDatabase && Event.current.keyCode == KeyCode.Escape && Event.current.type == EventType.KeyUp) //rename database button { if (!renamingThisDatabase && EditorUtility.DisplayDialog(UILabels.RenameSoundDatabase + " '" + soundDatabase.DatabaseName + "'", UILabels.RenameSoundDatabaseDialogMessage + "\n\n" + UILabels.YouAreResponsibleToUpdateYourCode, UILabels.Continue, UILabels.Cancel)) { StartRenameSoundDatabase(soundDatabase); Instance.Focus(); } else { ResetRenameSoundDatabase(); } } if (DGUI.Button.IconButton.Cancel(BarHeight)) //delete database button { SoundyDatabase.DeleteDatabase(soundDatabase); break; } DGUI.AlphaGroup.End(); } } } GUILayout.EndHorizontal(); GUILayout.Space(DGUI.Properties.Space()); if (DGUI.FadeOut.Begin(searchEnabled.target ? 1 : soundDatabaseAnimBool.faded)) { GUILayout.BeginVertical(); //RENAME DATABASE if (renamingThisDatabase) { if (DGUI.FadeOut.Begin(renameSoundDatabaseAnimBool.faded, false)) { GUILayout.BeginVertical(); { GUILayout.Space(DGUI.Properties.Space() * renameSoundDatabaseAnimBool.faded); GUILayout.BeginHorizontal(GUILayout.Height(DGUI.Properties.SingleLineHeight + DGUI.Properties.Space(2))); { DrawDefaultViewHorizontalSpacing(); GUI.color = DGUI.Colors.BackgroundColor(RENAME_COLOR_NAME); DGUI.Label.Draw(UILabels.RenameTo, Size.S, DGUI.Properties.SingleLineHeight + DGUI.Properties.Space(2)); //rename to label GUI.SetNextControlName(RENAME); m_newSoundDatabaseName = EditorGUILayout.TextField(GUIContent.none, m_newSoundDatabaseName); //rename to field GUI.color = InitialGUIColor; if (DGUI.Button.IconButton.Ok() || Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyUp) //rename OK button { Instance.Focus(); if (SoundyDatabase.RenameSoundDatabase(soundDatabase, m_newSoundDatabaseName)) { GetSoundDatabaseAnimBool(m_newSoundDatabaseName).value = true; ResetRenameSoundDatabase(); break; } } if (DGUI.Button.IconButton.Cancel() || Event.current.keyCode == KeyCode.Escape && Event.current.type == EventType.KeyUp) //rename CANCEL button { ResetRenameSoundDatabase(); } EditorGUI.FocusTextInControl(RENAME); DrawDefaultViewHorizontalSpacing(); } GUILayout.EndHorizontal(); GUILayout.Space(DGUI.Properties.Space(4) * renameSoundDatabaseAnimBool.faded); } GUILayout.EndVertical(); GUI.color = InitialGUIColor; } DGUI.FadeOut.End(renameSoundDatabaseAnimBool, false); } GUILayout.Space(DGUI.Properties.Space() * soundDatabaseAnimBool.faded); if (!searchEnabled.target) { float barIconSize = DGUI.Properties.SingleLineHeight * 0.8f; float barIconRowHeight = DGUI.Properties.SingleLineHeight - 1; GUILayout.BeginHorizontal(); { SoundDatabase database = soundDatabase; DGUI.Line.Draw(true, mixerColorName, () => { if (database.OutputAudioMixerGroup == null) { DGUI.Colors.SetDisabledGUIColorAlpha(); } DGUI.Icon.Draw(Styles.GetStyle(Styles.StyleName.IconAudioMixerGroup), barIconSize, barIconRowHeight, mixerColorName); //mixer icon GUILayout.Space(DGUI.Properties.Space()); DGUI.Label.Draw(UILabels.OutputMixerGroup, Size.S, mixerColorName, DGUI.Properties.SingleLineHeight); //mixer label GUI.color = InitialGUIColor; AudioMixerGroup outputAudioMixerGroup = database.OutputAudioMixerGroup; GUI.color = DGUI.Colors.GetDColor(mixerColorName).Light.WithAlpha(GUI.color.a); GUILayout.BeginVertical(GUILayout.Height(DGUI.Properties.SingleLineHeight)); { GUILayout.Space(0f); EditorGUI.BeginChangeCheck(); outputAudioMixerGroup = (AudioMixerGroup)EditorGUILayout.ObjectField(GUIContent.none, outputAudioMixerGroup, typeof(AudioMixerGroup), false); //mixer field if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(database, "Update AudioMixerGroup"); database.OutputAudioMixerGroup = outputAudioMixerGroup; database.SetDirty(true); } } GUILayout.EndVertical(); GUI.color = InitialGUIColor; }); GUILayout.Space(DGUI.Button.IconButton.Width + DGUI.Properties.Space(4)); } GUILayout.EndHorizontal(); } GUILayout.Space(DGUI.Properties.Space(2) * soundDatabaseAnimBool.faded); float lineHeight = DGUI.Properties.SingleLineHeight; float iconSize = lineHeight * 0.8f; GUILayout.Label(GUIContent.none, GUILayout.ExpandWidth(true), GUILayout.Height(0)); Rect rect = GUILayoutUtility.GetLastRect(); float x; float y = rect.y; float totalWidth = rect.width; float buttonAndPlayerWidth = rect.width - DGUI.Properties.Space(6) - iconSize - DGUI.Button.IconButton.Width; float buttonWidth = buttonAndPlayerWidth * 0.4f; float playerWidth = buttonAndPlayerWidth - buttonWidth; foreach (SoundGroupData soundGroupData in soundDatabase.Database) { if (searchEnabled.target) { if (!Regex.IsMatch(soundGroupData.SoundName, m_soundySearchPattern, RegexOptions.IgnoreCase)) //regex search check { if (!m_soundySearchAudioClipNames) { continue; } if (soundGroupData.Sounds == null || soundGroupData.Sounds.Count == 0) { continue; } bool foundAudioClipMatch = false; foreach (AudioData audioData in soundGroupData.Sounds) { if (audioData == null || audioData.AudioClip == null) { continue; } if (!Regex.IsMatch(audioData.AudioClip.name, m_soundySearchPattern, RegexOptions.IgnoreCase)) { continue; } foundAudioClipMatch = true; break; } if (!foundAudioClipMatch) { continue; } } soundDatabaseContainsSearchedSound = true; } //draw check - if the item was scrolled out of view (up or down) -> do not draw it bool drawItem = y > m_scrollPosition.y + 16 || y < m_scrollPosition.y + ViewRect.height - 16; if (!drawItem) { continue; } bool removedEntry = false; GUILayout.Space(DGUI.Properties.Space() * soundDatabaseAnimBool.faded); GUILayout.Label(GUIContent.none, GUILayout.ExpandWidth(true), GUILayout.Height(lineHeight)); x = rect.x; y += DGUI.Properties.Space() * soundDatabaseAnimBool.faded; bool noSound = soundGroupData.SoundName.Equals(SoundyManager.NO_SOUND); //is no sound check bool isSelected = Selection.activeObject == soundGroupData; //selected check bool hasIssues = !noSound && soundGroupData.HasMissingAudioClips; //has issues check bool enabledState = GUI.enabled; GUI.enabled = !noSound; { SoundyAudioPlayer.Player player = SoundyAudioPlayer.GetPlayer(soundGroupData, soundDatabase.OutputAudioMixerGroup); //player reference ColorName buttonColorName = isSelected ? hasIssues ? ColorName.Red : CurrentViewColorName : DGUI.Colors.DisabledBackgroundColorName; ColorName buttonTextColorName = hasIssues ? ColorName.Red : CurrentViewColorName; // if (i % 2 == 0) if (player.IsPlaying) { var backgroundRect = new Rect(x - DGUI.Properties.Space(2), y - DGUI.Properties.Space(), totalWidth + DGUI.Properties.Space(4), lineHeight + DGUI.Properties.Space(2)); GUI.color = DGUI.Colors.BackgroundColor(buttonColorName).WithAlpha(0.6f); GUI.Label(backgroundRect, GUIContent.none, Styles.GetStyle(Styles.StyleName.BackgroundRound)); GUI.color = InitialGUIColor; } var iconRect = new Rect(x, y + (lineHeight - iconSize) / 2, iconSize, iconSize); if (!player.IsPlaying) { GUI.color = GUI.color.WithAlpha(DGUI.Utility.IsProSkin ? 0.4f : 0.6f); } DGUI.Icon.Draw(iconRect, Styles.GetStyle(noSound || hasIssues ? Styles.StyleName.IconMuteSound : Styles.StyleName.IconSound), DGUI.Colors.TextColor(hasIssues ? ColorName.Red : buttonTextColorName)); //speaker icon GUI.color = InitialGUIColor; x += iconSize; x += DGUI.Properties.Space(2); var buttonRect = new Rect(x, y - DGUI.Properties.Space(), buttonWidth, lineHeight + DGUI.Properties.Space(2)); if (DGUI.Button.Draw(buttonRect, soundGroupData.SoundName, Size.S, TextAlign.Left, buttonColorName, buttonTextColorName, isSelected)) //select button { Selection.activeObject = soundGroupData; } if (hasIssues) { var errorIconRect = new Rect(buttonRect.xMax - iconSize - DGUI.Properties.Space(2), buttonRect.y + (buttonRect.height - iconSize) / 2, iconSize, iconSize); DGUI.Icon.Draw(errorIconRect, Styles.GetStyle(Styles.StyleName.IconError), Color.red); //issues icon } x += buttonWidth; x += DGUI.Properties.Space(2); var playerRect = new Rect(x, y, playerWidth, lineHeight); player.DrawPlayer(playerRect, buttonTextColorName); x += playerWidth; x += DGUI.Properties.Space(2); var deleteButtonRect = new Rect(x, y, DGUI.Button.IconButton.Width, DGUI.Button.IconButton.Height); if (DGUI.Button.IconButton.Minus(deleteButtonRect)) { bool wasSelected = Selection.activeObject == soundGroupData; if (soundDatabase.Remove(soundGroupData, true)) { if (wasSelected) { Selection.activeObject = null; } soundDatabase.SetDirty(true); if (player.IsPlaying) { player.Stop(); } removedEntry = true; } } y += lineHeight; y += DGUI.Properties.Space(2) * soundDatabaseAnimBool.faded; } GUI.enabled = enabledState; GUILayout.Space(DGUI.Properties.Space() * soundDatabaseAnimBool.faded); if (removedEntry) { break; } } GUILayout.Space(DGUI.Properties.Space() * soundDatabaseAnimBool.faded); if (!searchEnabled.target) { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); DrawSoundDatabaseDropZone(soundDatabase); GUILayout.Space(DGUI.Properties.Space()); if (DGUI.Button.IconButton.Plus()) { Selection.activeObject = soundDatabase.Add(SoundyManager.NEW_SOUND_GROUP, true, true); } } GUILayout.EndHorizontal(); } GUI.enabled = !(GetAnimBool(RENAME_SOUND_DATABASE).target&& renamingThisDatabase); GUILayout.EndVertical(); } DGUI.FadeOut.End(searchEnabled.target ? 1 : soundDatabaseAnimBool.faded); if (searchEnabled.target) { if (soundDatabaseContainsSearchedSound && !m_soundDatabasesWithSearchedSoundNames.Contains(soundDatabase)) { m_soundDatabasesWithSearchedSoundNames.Add(soundDatabase); soundDatabaseAnimBool.target = true; } else if (!soundDatabaseContainsSearchedSound && m_soundDatabasesWithSearchedSoundNames.Contains(soundDatabase)) { m_soundDatabasesWithSearchedSoundNames.Remove(soundDatabase); soundDatabaseAnimBool.target = false; } } } GUILayout.EndVertical(); DrawViewHorizontalPadding(); } GUILayout.EndHorizontal(); } if (foundNullReference) { SoundyDatabase.RefreshDatabase(false); } }
private static void StopAllSounds() { SoundyAudioPlayer.StopAllPlayers(); }
protected override void OnDisable() { base.OnDisable(); SoundyAudioPlayer.StopAllPlayers(); ResetSimulatorTween(true, false); }