Ejemplo n.º 1
0
    private void AddSFX(AudioClip clip, int groupIndex, int prepoolAmount, float baseVolume, float volumeVariation, float pitchVariation)
    {
        if (clip == null)
        {
            return;
        }
        SoundManagerEditorTools.RegisterObjectChange("Add SFX", script);
        script.storedSFXs.Add(clip);
        script.sfxPrePoolAmounts.Add(prepoolAmount);
        script.sfxBaseVolumes.Add(baseVolume);
        script.sfxVolumeVariations.Add(volumeVariation);
        script.sfxPitchVariations.Add(pitchVariation);
        script.showSFXDetails.Add(false);
        if (script.groupAddIndex > 0)
        {
            AddToGroup(clip.name, GetAvailableGroups()[script.groupAddIndex]);
        }
        else
        {
            EditorUtility.SetDirty(script);

            SceneView.RepaintAll();
        }
        QueryDict("AddSFX");
    }
Ejemplo n.º 2
0
    private void RemoveSFX(int index)
    {
        SoundManagerEditorTools.RegisterObjectChange("Remove SFX", script);
        string clipName = "";

        if (script.pocketClips[index] != null)
        {
            clipName = script.pocketClips[index].name;
        }
        script.pocketClips.RemoveAt(index);
        script.sfxPrePoolAmounts.RemoveAt(index);
        script.sfxBaseVolumes.RemoveAt(index);
        script.sfxVolumeVariations.RemoveAt(index);
        script.sfxPitchVariations.RemoveAt(index);
        script.showSFXDetails.RemoveAt(index);
        if (!string.IsNullOrEmpty(clipName))
        {
            if (IsInAGroup(clipName))
            {
                RemoveFromGroup(clipName);
            }
        }
        else
        {
            RemoveTracesOfIndex(index);
        }
        InitSFX();
        EditorUtility.SetDirty(script);

        SceneView.RepaintAll();
    }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
 private void RemoveSoundConnection(int index)
 {
     SoundManagerEditorTools.RegisterObjectChange("Remove SoundConnection", script);
     script.soundConnections.RemoveAt(index);
     RecalculateBools();
     EditorUtility.SetDirty(script);
     SceneView.RepaintAll();
 }
Ejemplo n.º 5
0
 private void RemoveEvent(int index)
 {
     if (index >= script.numSubscriptions || index < 0)
     {
         return;
     }
     SoundManagerEditorTools.RegisterObjectChange("Remove Event", script);
     script.numSubscriptions--;
     script.audioSubscriptions.RemoveAt(index);
     EditorUtility.SetDirty(script);
 }
Ejemplo n.º 6
0
    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();
    }
Ejemplo n.º 7
0
    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();
    }
Ejemplo n.º 8
0
    private void ShowPocketName()
    {
        EditorGUILayout.LabelField(new GUIContent("Pocket Name", "Name of the SoundPocket. If a SoundPocket already exists on the SoundManager, it will not be readded."), EditorStyles.boldLabel, GUILayout.ExpandWidth(false));

        string pocketName = script.pocketName;

        pocketName = EditorGUILayout.TextField(pocketName);
        if (pocketName != script.pocketName)
        {
            SoundManagerEditorTools.RegisterObjectChange("Change Pocket Name", script);
            script.pocketName = pocketName;
            EditorUtility.SetDirty(script);
        }
    }
Ejemplo n.º 9
0
    private void ShowPocketType()
    {
        EditorGUILayout.LabelField(new GUIContent("Pocket Type", "Determines how this pocket will be added to the SoundManager once the SoundPocket is loaded. If additive, these SFX will be added to the SoundManager. If subtractive, the SFX currently on the SoundManager will be removed before these are added."), EditorStyles.boldLabel, GUILayout.ExpandWidth(false));

        SoundPocketType pocketType = script.pocketType;

        pocketType = (SoundPocketType)EditorGUILayout.EnumPopup(pocketType);
        if (pocketType != script.pocketType)
        {
            SoundManagerEditorTools.RegisterObjectChange("Change Pocket Type", script);
            script.pocketType = pocketType;
            EditorUtility.SetDirty(script);
        }
    }
Ejemplo n.º 10
0
 private void AddEvent()
 {
     SoundManagerEditorTools.RegisterObjectChange("Add Event", script);
     script.numSubscriptions++;
     script.audioSubscriptions.Add(new AudioSubscription());
     if (script.numSubscriptions == 1)
     {
         script.audioSubscriptions[script.audioSubscriptions.Count - 1].sourceComponent = null;
     }
     else
     {
         script.audioSubscriptions[script.audioSubscriptions.Count - 1].sourceComponent = script.audioSubscriptions[script.audioSubscriptions.Count - 2].sourceComponent;
     }
     EditorUtility.SetDirty(script);
 }
Ejemplo n.º 11
0
    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();
    }
Ejemplo n.º 12
0
    private void RemoveGroup(int index)
    {
        SoundManagerEditorTools.RegisterObjectChange("Remove Group", script);
        string groupName = script.sfxGroups[index].groupName;

        RemoveAllInGroup(groupName);
        script.sfxGroups.RemoveAt(index);
        if (clipsByGroup.ContainsKey(index))
        {
            clipsByGroup.Remove(index);
        }
        InitSFX();
        EditorUtility.SetDirty(script);
        SceneView.RepaintAll();
        QueryDict("RemoveGroup");
    }
Ejemplo n.º 13
0
    private void AddGroup(string groupName, int capAmount)
    {
        if (AlreadyContainsGroup(groupName))
        {
            return;
        }

        SoundManagerEditorTools.RegisterObjectChange("Add Group", script);
        script.sfxGroups.Add(new SFXGroup(groupName, capAmount));
        if (!clipsByGroup.ContainsKey(script.sfxGroups.Count - 1))
        {
            clipsByGroup.Add(script.sfxGroups.Count - 1, new List <int>());
        }

        EditorUtility.SetDirty(script);

        SceneView.RepaintAll();
        QueryDict("AddGroup");
    }
Ejemplo n.º 14
0
    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();
    }
Ejemplo n.º 15
0
    private void ChangeGroup(string clipName, int previousIndex, int nextIndex, string groupName)
    {
        SoundManagerEditorTools.RegisterObjectChange("Change Group", script);
        if (previousIndex == 0)        //wasnt in group, so add it
        {
            AddToGroup(clipName, groupName);
        }
        else if (nextIndex == 0)         //was in group but now doesn't want to be
        {
            RemoveFromGroup(clipName);
        }
        else         //just changing groups
        {
            int index         = IndexOfKey(clipName);
            int groupIndex    = IndexOfGroup(groupName);
            int clipIndex     = IndexOfClip(clipName);
            int oldGroupIndex = IndexOfGroup(script.clipToGroupValues[index]);

            script.clipToGroupValues[index] = groupName;

            if (clipsByGroup.ContainsKey(groupIndex))
            {
                clipsByGroup[oldGroupIndex].Remove(clipIndex);
                clipsByGroup[groupIndex].Add(clipIndex);
            }
            else
            {
                clipsByGroup.Add(groupIndex, new List <int>()
                {
                    clipIndex
                });
            }

            EditorUtility.SetDirty(script);
        }
        InitSFX();
    }
Ejemplo n.º 16
0
    private void ShowSFXGroupNames()
    {
        EditorGUILayout.LabelField(new GUIContent("SFXGroup Names", "These are possible group names for SFXs to be applied to. If the group exists on the SoundManager, it'll be added to that group. Otherwise, a new group will be created."), EditorStyles.boldLabel, GUILayout.ExpandWidth(false));

        for (int i = 0; i < script.sfxGroups.Count; i++)
        {
            string grpName = script.sfxGroups[i];
            grpName = EditorGUILayout.TextField(grpName);
            if (grpName != script.sfxGroups[i])
            {
                SoundManagerEditorTools.RegisterObjectChange("Change Pocket Group Name", script);
                script.sfxGroups[i] = grpName;
                EditorUtility.SetDirty(script);
            }
        }
        EditorGUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("+"))
            {
                SoundManagerEditorTools.RegisterObjectChange("Add Pocket Group Name", script);
                script.sfxGroups.Add("");
                EditorUtility.SetDirty(script);
            }
            if (script.sfxGroups.Count <= 0)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("-"))
            {
                SoundManagerEditorTools.RegisterObjectChange("Remove Pocket Group Name", script);
                script.sfxGroups.RemoveAt(script.sfxGroups.Count - 1);
                EditorUtility.SetDirty(script);
            }
            GUI.enabled = true;
        }
        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 17
0
    private void ShowDeveloperSettings()
    {
        EditorGUI.indentLevel++;
        {
            bool showDebug = script.showDebug;
            showDebug = EditorGUILayout.Toggle("Show Debug Info:", showDebug);
            if (showDebug != script.showDebug)
            {
                SoundManagerEditorTools.RegisterObjectChange("Change Show Debug", script);
                script.showDebug = showDebug;
                EditorUtility.SetDirty(script);
            }

            bool ignoreLevelLoad = script.ignoreLevelLoad;
            ignoreLevelLoad = EditorGUILayout.Toggle("Ignore Level Load:", ignoreLevelLoad);
            if (ignoreLevelLoad != script.ignoreLevelLoad)
            {
                SoundManagerEditorTools.RegisterObjectChange("Set Ignore Level Load", script);
                script.ignoreLevelLoad = ignoreLevelLoad;
                EditorUtility.SetDirty(script);
            }

            bool offTheBGM = script.offTheBGM;
            offTheBGM = EditorGUILayout.Toggle("Music Always Off:", offTheBGM);
            if (offTheBGM != script.offTheBGM)
            {
                SoundManagerEditorTools.RegisterObjectChange("Toggle BGM", script);
                script.offTheBGM = offTheBGM;
                EditorUtility.SetDirty(script);
            }

            bool offTheSFX = script.offTheSFX;
            offTheSFX = EditorGUILayout.Toggle("SFX Always Off:", offTheSFX);
            if (offTheSFX != script.offTheSFX)
            {
                SoundManagerEditorTools.RegisterObjectChange("Toggle SFX", script);
                script.offTheSFX = offTheSFX;
                EditorUtility.SetDirty(script);
            }

            int capAmount = script.capAmount;
            capAmount = EditorGUILayout.IntField("SFX Cap Amount:", capAmount, GUILayout.Width(3f * Screen.width / 4f));
            if (capAmount < 0)
            {
                capAmount = 0;
            }
            if (capAmount != script.capAmount)
            {
                SoundManagerEditorTools.RegisterObjectChange("Change SFX Cap Amount", script);
                script.capAmount = capAmount;
                EditorUtility.SetDirty(script);
            }

            float SFXObjectLifetime = script.SFXObjectLifetime;
            SFXObjectLifetime = EditorGUILayout.FloatField("SFX Object Lifetime:", SFXObjectLifetime, GUILayout.Width(3f * Screen.width / 4f));
            if (SFXObjectLifetime < 1f)
            {
                SFXObjectLifetime = 1f;
            }
            if (SFXObjectLifetime != script.SFXObjectLifetime)
            {
                SoundManagerEditorTools.RegisterObjectChange("Change SFX Object Lifetime", script);
                script.SFXObjectLifetime = SFXObjectLifetime;
                EditorUtility.SetDirty(script);
            }

            string resourcesPath = script.resourcesPath;
            resourcesPath = EditorGUILayout.TextField("Default Load Path:", resourcesPath, GUILayout.Width(3f * Screen.width / 4f));
            if (resourcesPath != script.resourcesPath)
            {
                SoundManagerEditorTools.RegisterObjectChange("Change Default Load Path", script);
                script.resourcesPath = resourcesPath;
                EditorUtility.SetDirty(script);
            }
        }
        EditorGUI.indentLevel--;
        EditorGUILayout.Space();
    }
Ejemplo n.º 18
0
    private void ShowSoundFXGroupsList()
    {
        EditorGUILayout.BeginVertical();
        {
            EditorGUI.indentLevel++;
            if (script.helpOn)
            {
                EditorGUILayout.HelpBox("SFX Groups are used to:\n1. Access random clips in a set.\n2. Apply specific cap amounts to clips when using SoundManager.PlayCappedSFX." +
                                        "\n\n-Setting the cap amount to -1 will make a group use the default SFX Cap Amount\n\n-Setting the cap amount to 0 will make a group not use a cap at all.", MessageType.Info);
            }
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Group Name:", GUILayout.ExpandWidth(true));
                EditorGUILayout.LabelField("Cap:", GUILayout.Width(40f));
                bool helpOn = script.helpOn;
                helpOn = GUILayout.Toggle(helpOn, "?", GUI.skin.button, GUILayout.Width(35f));
                if (helpOn != script.helpOn)
                {
                    SoundManagerEditorTools.RegisterObjectChange("Change SFXGroup Help", script);
                    script.helpOn = helpOn;
                    EditorUtility.SetDirty(script);
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("", GUILayout.Width(10f));
                GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
            }
            EditorGUILayout.EndHorizontal();

            for (int i = 0; i < script.sfxGroups.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                {
                    SFXGroup grp = script.sfxGroups[i];

                    if (grp != null)
                    {
                        EditorGUILayout.LabelField(grp.groupName, GUILayout.ExpandWidth(true));
                        int  specificCapAmount = grp.specificCapAmount;
                        bool isAuto = false, isNo = false;

                        if (specificCapAmount == -1)
                        {
                            isAuto = true;
                        }
                        else if (specificCapAmount == 0)
                        {
                            isNo = true;
                        }

                        bool newAuto = GUILayout.Toggle(isAuto, "Auto Cap", GUI.skin.button, GUILayout.ExpandWidth(false));
                        bool newNo   = GUILayout.Toggle(isNo, "No Cap", GUI.skin.button, GUILayout.ExpandWidth(false));

                        if (newAuto != isAuto && newAuto)
                        {
                            specificCapAmount = -1;
                        }
                        if (newNo != isNo && newNo)
                        {
                            specificCapAmount = 0;
                        }

                        specificCapAmount = EditorGUILayout.IntField(specificCapAmount, GUILayout.Width(40f));
                        if (specificCapAmount < -1)
                        {
                            specificCapAmount = -1;
                        }

                        if (specificCapAmount != grp.specificCapAmount)
                        {
                            SoundManagerEditorTools.RegisterObjectChange("Change Group Cap", script);
                            grp.specificCapAmount = specificCapAmount;
                            EditorUtility.SetDirty(script);
                        }

                        EditorGUILayout.LabelField("", GUILayout.Width(10f));
                        GUI.color = Color.red;
                        if (GUILayout.Button("X", GUILayout.Width(20f)))
                        {
                            RemoveGroup(i);
                            return;
                        }
                        GUI.color = Color.white;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            ShowAddGroup();
            EditorGUI.indentLevel--;
            EditorGUILayout.Space();
        }
        EditorGUILayout.EndVertical();
    }
Ejemplo n.º 19
0
    private void ShowInfo()
    {
        EditorGUI.indentLevel++;
        {
            EditorGUILayout.LabelField("Current Scene:", Application.loadedLevelName);

            float crossDuration = script.crossDuration;
            crossDuration = EditorGUILayout.FloatField("Cross Duration:", crossDuration);
            if (crossDuration < 0)
            {
                crossDuration = 0f;
            }
            if (crossDuration != script.crossDuration)
            {
                SoundManagerEditorTools.RegisterObjectChange("Change Cross Duration", script);
                script.crossDuration = crossDuration;
                EditorUtility.SetDirty(script);
            }

            int audioSize = 0;
            if (script.audios != null && script.audios[0] != null && script.audios[1] != null)
            {
                audioSize = script.audios.Length;
            }
            if (audioSize != 0)
            {
                string name1, name2;
                name1 = name2 = "No Song";

                GUI.color = hardGreen;
                if (script.audios[0] && script.audios[0].clip)
                {
                    name1 = script.audios[0].clip.name;
                }
                else
                {
                    GUI.color = Color.red;
                }

                Rect rect = GUILayoutUtility.GetRect(28, 28, "TextField");
                if (name1 != "No Song")
                {
                    name1 += "\n" + System.TimeSpan.FromSeconds(script.audios[0].time).ToString().Split('.')[0] + "/" + System.TimeSpan.FromSeconds(script.audios[0].clip.length).ToString().Split('.')[0];
                }
                EditorGUI.ProgressBar(rect, script.audios[0].volume, name1);

                GUI.color = hardGreen;
                if (script.audios[1] && script.audios[1].clip)
                {
                    name2 = script.audios[1].clip.name;
                }
                else
                {
                    GUI.color = Color.red;
                }

                Rect rect2 = GUILayoutUtility.GetRect(28, 28, "TextField");
                if (name2 != "No Song")
                {
                    name2 += "\n" + System.TimeSpan.FromSeconds(script.audios[1].time).ToString().Split('.')[0] + "/" + System.TimeSpan.FromSeconds(script.audios[1].clip.length).ToString().Split('.')[0];
                }
                EditorGUI.ProgressBar(rect2, script.audios[1].volume, name2);

                GUI.color = Color.white;
                Repaint();
            }
            else
            {
                GUI.color = Color.red;
                Rect rect = GUILayoutUtility.GetRect(28, 28, "TextField");
                EditorGUI.ProgressBar(rect, 0f, "Standing By...");

                Rect rect2 = GUILayoutUtility.GetRect(28, 28, "TextField");
                EditorGUI.ProgressBar(rect2, 0f, "Standing By...");
                GUI.color = Color.white;
            }
        }
        EditorGUI.indentLevel--;
        EditorGUILayout.Space();
    }
Ejemplo n.º 20
0
    private void ShowIndividualSFXAtIndex(int i, string[] groups, GUIContent expandContent)
    {
        if (i >= script.pocketClips.Count)
        {
            return;
        }
        AudioClip obj = script.pocketClips[i];

        if (obj != null)
        {
            EditorGUILayout.BeginHorizontal();
            {
                AudioClip newClip = (AudioClip)EditorGUILayout.ObjectField(obj, typeof(AudioClip), false);
                if (newClip != obj)
                {
                    if (newClip == null)
                    {
                        RemoveSFX(i);
                        return;
                    }
                    else
                    {
                        SoundManagerEditorTools.RegisterObjectChange("Change SFX", script);
                        obj = newClip;
                        EditorUtility.SetDirty(script);
                    }
                }
                if ((script.showSFXDetails[i] && GUILayout.Button("-", GUILayout.Width(30f))) || (!script.showSFXDetails[i] && GUILayout.Button(expandContent, GUILayout.Width(30f))))
                {
                    script.showSFXDetails[i] = !script.showSFXDetails[i];
                }

                GUI.color = Color.red;
                if (GUILayout.Button("X", GUILayout.Width(20f)))
                {
                    RemoveSFX(i);
                    return;
                }
                GUI.color = Color.white;
            }
            EditorGUILayout.EndHorizontal();

            if (script.showSFXDetails[i])
            {
                EditorGUI.indentLevel += 4;
                string clipName = obj.name;
                int    oldIndex = IndexOfKey(clipName);
                if (oldIndex >= 0)                // if in a group, find index
                {
                    int clipIndex = oldIndex;
                    oldIndex = IndexOfGroup(script.clipToGroupValues[oldIndex]);
                    if (oldIndex < 0)                    // if group no longer exists as it was, set it to none
                    {
                        oldIndex = 0;
                        script.clipToGroupKeys.RemoveAt(clipIndex);
                        script.clipToGroupValues.RemoveAt(clipIndex);
                    }
                }
                if (oldIndex < 0)                // if not in a group, set it to none
                {
                    oldIndex = 0;
                }
                else                 //if in a group, add 1 to index to cover for None group type
                {
                    oldIndex++;
                }

                int newIndex = EditorGUILayout.Popup("Group:", oldIndex, groups, EditorStyles.popup);
                if (oldIndex != newIndex)
                {
                    string groupName = groups[newIndex];
                    ChangeGroup(clipName, oldIndex, newIndex, groupName);
                    return;
                }

                int prepoolAmount = script.sfxPrePoolAmounts[i];

                prepoolAmount = EditorGUILayout.IntField(new GUIContent("Prepool Amount:", "Minimum amount of SFX objects for this clip waiting in the pool on standby. Good for performance."), prepoolAmount);
                if (prepoolAmount < 0)
                {
                    prepoolAmount = 0;
                }
                if (prepoolAmount != script.sfxPrePoolAmounts[i])
                {
                    SoundManagerEditorTools.RegisterObjectChange("Change Prepool Amount", script);
                    script.sfxPrePoolAmounts[i] = prepoolAmount;
                    EditorUtility.SetDirty(script);
                }

                float baseVolume = script.sfxBaseVolumes[i];

                baseVolume = EditorGUILayout.FloatField(new GUIContent("Base Volume:", "Base volume for this AudioClip. Lower this value if you don't want this AudioClip to play as loud. When in doubt, keep this at 1."), baseVolume);
                if (baseVolume < 0f)
                {
                    baseVolume = 0f;
                }
                else if (baseVolume > 1f)
                {
                    baseVolume = 1f;
                }
                if (baseVolume != script.sfxBaseVolumes[i])
                {
                    SoundManagerEditorTools.RegisterObjectChange("Change Base Volume", script);
                    script.sfxBaseVolumes[i] = baseVolume;
                    EditorUtility.SetDirty(script);
                }

                float volumeVariation = script.sfxVolumeVariations[i];

                volumeVariation = EditorGUILayout.FloatField(new GUIContent("Volume Variation:", "Let's you vary the volume of this clip each time it's played. You get a much greater impact if you randomly vary pitch and volume between 3% and 5% each time that sound is played. So keep this value low: ~0.05"), volumeVariation);
                if (volumeVariation < 0f)
                {
                    volumeVariation = 0f;
                }
                else if (volumeVariation > 1f)
                {
                    volumeVariation = 1f;
                }
                if (volumeVariation != script.sfxVolumeVariations[i])
                {
                    SoundManagerEditorTools.RegisterObjectChange("Change Volume Variation", script);
                    script.sfxVolumeVariations[i] = volumeVariation;
                    EditorUtility.SetDirty(script);
                }

                float pitchVariation = script.sfxPitchVariations[i];

                pitchVariation = EditorGUILayout.FloatField(new GUIContent("Pitch Variation:", "Let's you vary the pitch of this clip each time it's played. You get a much greater impact if you randomly vary pitch and volume between 3% and 5% each time that sound is played. So keep this value low: ~0.025"), pitchVariation);
                if (pitchVariation < 0f)
                {
                    pitchVariation = 0f;
                }
                else if (pitchVariation > 1f)
                {
                    pitchVariation = 1f;
                }
                if (pitchVariation != script.sfxPitchVariations[i])
                {
                    SoundManagerEditorTools.RegisterObjectChange("Change Pitch Variation", script);
                    script.sfxPitchVariations[i] = pitchVariation;
                    EditorUtility.SetDirty(script);
                }
                EditorGUI.indentLevel -= 4;
            }
        }
    }
Ejemplo n.º 21
0
    public override void OnInspectorGUI()
    {
        if (source == null)
        {
            return;
        }
        #region ClipType handler
        ClipType clipType = script.clipType;
        clipType = (ClipType)EditorGUILayout.EnumPopup("Clip Type", clipType);
        if (clipType != script.clipType)
        {
            SoundManagerEditorTools.RegisterObjectChange("Change Clip Type", script);
            script.clipType = clipType;
            if (script.clipType != ClipType.AudioClip)
            {
                source.clip = null;
            }
            EditorUtility.SetDirty(script);
        }

        switch (script.clipType)
        {
        case ClipType.ClipFromSoundManager:
            string clipName = script.clipName;
            clipName = EditorGUILayout.TextField("Audio Clip Name", clipName);
            if (clipName != script.clipName)
            {
                SoundManagerEditorTools.RegisterObjectChange("Change Clip Name", script);
                script.clipName = clipName;
                EditorUtility.SetDirty(script);
            }
            break;

        case ClipType.ClipFromGroup:
            string groupName = script.groupName;
            groupName = EditorGUILayout.TextField("SFXGroup Name", groupName);
            if (groupName != script.groupName)
            {
                SoundManagerEditorTools.RegisterObjectChange("Change SFXGroup Name", script);
                script.groupName = groupName;
                EditorUtility.SetDirty(script);
            }
            break;

        case ClipType.AudioClip:
        default:
            AudioClip clip = source.clip;
            clip = EditorGUILayout.ObjectField("Audio Clip", clip, typeof(AudioClip), false) as AudioClip;
            if (clip != source.clip)
            {
                SoundManagerEditorTools.RegisterObjectChange("Change Audio Clip", script);
                source.clip = clip;
                EditorUtility.SetDirty(script);
            }
            break;
        }
        #endregion

        #region audio source settings
        EditorGUILayout.Space();
        UnityEngine.Audio.AudioMixerGroup outputAudioMixerGroup = source.outputAudioMixerGroup;
        outputAudioMixerGroup = EditorGUILayout.ObjectField("Output", outputAudioMixerGroup, typeof(UnityEngine.Audio.AudioMixerGroup), false) as UnityEngine.Audio.AudioMixerGroup;
        if (outputAudioMixerGroup != source.outputAudioMixerGroup)
        {
            SoundManagerEditorTools.RegisterObjectChange("Change Output AudioMixerGroup", script);
            source.outputAudioMixerGroup = outputAudioMixerGroup;
            EditorUtility.SetDirty(script);
        }
        source.mute                  = EditorGUILayout.Toggle("Mute", source.mute);
        source.bypassEffects         = EditorGUILayout.Toggle("Bypass Effects", source.bypassEffects);
        source.bypassListenerEffects = EditorGUILayout.Toggle("Bypass Listener Effects", source.bypassListenerEffects);
        source.bypassReverbZones     = EditorGUILayout.Toggle("Bypass Reverb Zones", source.bypassReverbZones);
        source.playOnAwake           = EditorGUILayout.Toggle("Play On Awake", source.playOnAwake);
        source.loop                  = EditorGUILayout.Toggle("Loop", source.loop);
        EditorGUILayout.Space();
        source.priority = EditorGUILayout.IntSlider("Priority", source.priority, 0, 256);
        EditorGUILayout.Space();
        source.volume = EditorGUILayout.Slider("Volume", source.volume, 0f, 1f);
        EditorGUILayout.Space();
        source.pitch = EditorGUILayout.Slider("Pitch", source.pitch, -3f, 3f);
        EditorGUILayout.Space();
        source.panStereo = EditorGUILayout.Slider("Stereo Pan", source.panStereo, -1f, 1f);
        EditorGUILayout.Space();
        source.spatialBlend = EditorGUILayout.Slider("Spatial Blend", source.spatialBlend, 0f, 1f);
        EditorGUILayout.Space();
        source.reverbZoneMix = EditorGUILayout.Slider("Reverb Zone Mix", source.reverbZoneMix, 0f, 1.1f);
        EditorGUILayout.Space();

        script.ShowEditor3D = EditorGUILayout.Foldout(script.ShowEditor3D, "3D Sound Settings");
        if (script.ShowEditor3D)
        {
            EditorGUI.indentLevel++;
            {
                source.dopplerLevel = EditorGUILayout.Slider("Doppler Level", source.dopplerLevel, 0f, 5f);
                EditorGUILayout.Space();
                AudioRolloffMode mode = source.rolloffMode;
                mode = (AudioRolloffMode)EditorGUILayout.EnumPopup("Volume Rolloff", mode);
                if (mode != AudioRolloffMode.Custom)
                {
                    source.rolloffMode = mode;
                    if (GUI.changed && notAvailable)
                    {
                        notAvailable = false;
                    }
                }
                else
                {
                    notAvailable = true;
                }

                if (notAvailable)
                {
                    GUI.color              = Color.red;
                    EditorGUI.indentLevel += 2;
                    {
                        EditorGUILayout.LabelField("Custom Volume Rolloff not available", EditorStyles.whiteLabel);
                    }
                    EditorGUI.indentLevel -= 2;
                    GUI.color              = Color.white;
                }
                EditorGUI.indentLevel++;
                {
                    float minD = source.minDistance;
                    minD = EditorGUILayout.FloatField("Min Distance", minD);
                    if (minD < 0f)
                    {
                        minD = 0f;
                    }
                    source.minDistance = minD;
                }
                EditorGUI.indentLevel--;
                source.spread = EditorGUILayout.Slider("Spread", source.spread, 0f, 360f);

                float maxD = source.maxDistance;
                maxD = EditorGUILayout.FloatField("Max Distance", maxD);
                if (maxD < source.minDistance + 3f)
                {
                    maxD = source.minDistance + 3f;
                }
                source.maxDistance = maxD;

                if (GUI.changed)
                {
                    CalculateCurve();
                }

                GUI.enabled = false;
                EditorGUILayout.BeginHorizontal();
                {
                    curve        = EditorGUILayout.CurveField(curve, Color.red, new Rect(0f, 0f, source.maxDistance, 1f), GUILayout.Height(100f), GUILayout.ExpandWidth(false));
                    spatialCurve = EditorGUILayout.CurveField(spatialCurve, Color.green, new Rect(0f, 0f, source.maxDistance, 1f), GUILayout.Height(100f), GUILayout.ExpandWidth(false));
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    GUI.color = Color.red;
                    EditorGUILayout.TextArea("", EditorStyles.miniButton, GUILayout.Width(30f), GUILayout.Height(15f), GUILayout.ExpandWidth(false));
                    GUI.color   = Color.white;
                    GUI.enabled = true;
                    GUILayout.Label("Volume");
                    GUI.enabled = false;

                    GUI.color = Color.green;
                    EditorGUILayout.TextArea("", EditorStyles.miniButton, GUILayout.Width(30f), GUILayout.Height(15f), GUILayout.ExpandWidth(false));
                    GUI.color   = Color.white;
                    GUI.enabled = true;
                    GUILayout.Label("Spatial");
                    GUI.enabled = false;

                    GUI.color = Color.white;
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    spreadCurve = EditorGUILayout.CurveField(spreadCurve, Color.blue, new Rect(0f, 0f, source.maxDistance, 360f), GUILayout.Height(100f), GUILayout.ExpandWidth(false));
                    reverbCurve = EditorGUILayout.CurveField(reverbCurve, Color.yellow, new Rect(0f, 0f, source.maxDistance, 1.1f), GUILayout.Height(100f), GUILayout.ExpandWidth(false));
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                {
                    GUI.color = Color.blue;
                    EditorGUILayout.TextArea("", EditorStyles.miniButton, GUILayout.Width(30f), GUILayout.Height(15f), GUILayout.ExpandWidth(false));
                    GUI.color   = Color.white;
                    GUI.enabled = true;
                    GUILayout.Label("Spread");
                    GUI.enabled = false;

                    GUI.color = Color.yellow;
                    EditorGUILayout.TextArea("", EditorStyles.miniButton, GUILayout.Width(30f), GUILayout.Height(15f), GUILayout.ExpandWidth(false));
                    GUI.color   = Color.white;
                    GUI.enabled = true;
                    GUILayout.Label("Reverb");
                    GUI.enabled = false;

                    GUI.color = Color.white;
                }
                EditorGUILayout.EndHorizontal();
                GUI.enabled = true;
            }
            EditorGUI.indentLevel--;
        }
        #endregion

        #region events
        EditorGUILayout.Space();
        script.ShowEventTriggers = EditorGUILayout.Foldout(script.ShowEventTriggers, "Event Trigger Settings");
        if (script.ShowEventTriggers)
        {
            for (int i = 0; i < script.numSubscriptions; i++)
            {
                EditorGUI.indentLevel++;
                {
                    EditorGUILayout.BeginVertical(EditorStyles.objectFieldThumb, GUILayout.ExpandWidth(true));
                    {
                        if (script.audioSubscriptions[i].sourceComponent == null)
                        {
                            EditorGUILayout.HelpBox("Drag a Component from THIS GameObject Below (Optional)", MessageType.None);
                        }

                        EditorGUILayout.BeginHorizontal();
                        var sourceComponent = ComponentField("Component", script.audioSubscriptions[i].sourceComponent);
                        if (GUILayout.Button("Clear"))
                        {
                            sourceComponent = null;
                        }
                        GUI.color = Color.red;
                        if (GUILayout.Button("Remove"))
                        {
                            RemoveEvent(i);
                            return;
                        }
                        GUI.color = Color.white;
                        if (sourceComponent != script.audioSubscriptions[i].sourceComponent)
                        {
                            SoundManagerEditorTools.RegisterObjectChange("Change Event Component", script);
                            script.audioSubscriptions[i].sourceComponent = sourceComponent;
                            EditorUtility.SetDirty(script);
                        }
                        EditorGUILayout.EndHorizontal();

                        int skippedStandardEvents = 0;

                        List <string> sourceComponentMembers = new List <string>();
                        if (sourceComponent != null)
                        {
                            sourceComponentMembers =
                                sourceComponent.GetType()
                                .GetEvents(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
                                .Where(f => f.EventHandlerType.GetMethod("Invoke").GetParameters().Length == 0 && f.EventHandlerType.GetMethod("Invoke").ReturnType == typeof(void) && !IsAlreadyBound(f.Name, i))
                                .Select(m => m.Name).ToList();
                        }

                        AudioSourceStandardEvent[] standardEvents = Enum.GetValues(typeof(AudioSourceStandardEvent)).Cast <AudioSourceStandardEvent>().ToArray();
                        foreach (AudioSourceStandardEvent standardEvent in standardEvents)
                        {
                            if (!IsAlreadyBound(standardEvent.ToString(), i))
                            {
                                sourceComponentMembers.Add(standardEvent.ToString());
                            }
                            else
                            {
                                skippedStandardEvents++;
                            }
                        }
                        sourceComponentMembers.Add(nullEvent);

                        int numStandardEvents = standardEvents.Length - skippedStandardEvents;

                        string[] sourceComponentMembersArray = sourceComponentMembers.ToArray();
                        var      memberIndex = findIndex(sourceComponentMembersArray, script.audioSubscriptions[i].methodName);

                        if (memberIndex == -1)
                        {
                            memberIndex = sourceComponentMembers.Count - 1;
                            script.audioSubscriptions[i].methodName = "";
                        }

                        var selectedIndex = EditorGUILayout.Popup("Compatible Events", memberIndex, sourceComponentMembersArray);
                        if (selectedIndex >= 0 && selectedIndex < sourceComponentMembersArray.Length)
                        {
                            var memberName = sourceComponentMembersArray[selectedIndex];
                            if (memberName != script.audioSubscriptions[i].methodName)
                            {
                                SoundManagerEditorTools.RegisterObjectChange("Change Event", script);
                                script.audioSubscriptions[i].methodName = memberName;
                                EditorUtility.SetDirty(script);
                            }
                        }
                        if (selectedIndex == sourceComponentMembersArray.Length - 1)
                        {
                            EditorGUILayout.HelpBox("No event configuration selected.", MessageType.None);
                        }
                        else if (selectedIndex < sourceComponentMembersArray.Length - numStandardEvents - 1 && !script.audioSubscriptions[i].componentIsValid)
                        {
#if !(UNITY_WP8 || UNITY_METRO)
                            EditorGUILayout.HelpBox("Configuration is invalid.", MessageType.Error);
#else
                            EditorGUILayout.HelpBox("Configuration is invalid. Keep in mind that custom event configurations are not supported in the Win8Phone and WinStore platforms.", MessageType.Error);
#endif
                        }
                        else
                        {
                            if (selectedIndex + numStandardEvents < sourceComponentMembersArray.Length - 1)
                            {
                                if (script.audioSubscriptions[i].isStandardEvent)
                                {
                                    script.BindStandardEvent(script.audioSubscriptions[i].standardEvent, false);
                                }
                                script.audioSubscriptions[i].isStandardEvent = false;
                            }
                            else
                            {
                                script.audioSubscriptions[i].isStandardEvent = true;
                                script.audioSubscriptions[i].standardEvent   = (AudioSourceStandardEvent)Enum.Parse(typeof(AudioSourceStandardEvent), sourceComponentMembersArray[selectedIndex]);
                                script.BindStandardEvent(script.audioSubscriptions[i].standardEvent, true);

                                if (IsColliderEvent(script.audioSubscriptions[i].standardEvent))
                                {
                                    EditorGUI.indentLevel += 2;
                                    {
                                        //tags
                                        EditorGUILayout.BeginHorizontal();

                                        bool filterTags = script.audioSubscriptions[i].filterTags;
                                        filterTags = EditorGUILayout.Toggle(filterTags, GUILayout.Width(40f));
                                        if (filterTags != script.audioSubscriptions[i].filterTags)
                                        {
                                            SoundManagerEditorTools.RegisterObjectChange("Filter Tags", script);
                                            script.audioSubscriptions[i].filterTags = filterTags;
                                            EditorUtility.SetDirty(script);
                                        }
                                        EditorGUILayout.LabelField("Filter Tags:", GUILayout.Width(110f));

                                        GUI.enabled = filterTags;
                                        int tagMask = script.audioSubscriptions[i].tagMask;
                                        tagMask = EditorGUILayout.MaskField(tagMask, UnityEditorInternal.InternalEditorUtility.tags, GUILayout.ExpandWidth(true));
                                        if (tagMask != script.audioSubscriptions[i].tagMask)
                                        {
                                            SoundManagerEditorTools.RegisterObjectChange("Change Tag Filter", script);
                                            script.audioSubscriptions[i].tagMask = tagMask;
                                            script.audioSubscriptions[i].tags.Clear();
                                            for (int t = 0; t < UnityEditorInternal.InternalEditorUtility.tags.Length; t++)
                                            {
                                                if ((tagMask & 1 << t) != 0)
                                                {
                                                    script.audioSubscriptions[i].tags.Add(UnityEditorInternal.InternalEditorUtility.tags[t]);
                                                }
                                            }
                                            EditorUtility.SetDirty(script);
                                        }
                                        GUI.enabled = true;

                                        EditorGUILayout.EndHorizontal();


                                        //layers
                                        EditorGUILayout.BeginHorizontal();

                                        bool filterLayers = script.audioSubscriptions[i].filterLayers;
                                        filterLayers = EditorGUILayout.Toggle(filterLayers, GUILayout.Width(40f));
                                        if (filterLayers != script.audioSubscriptions[i].filterLayers)
                                        {
                                            SoundManagerEditorTools.RegisterObjectChange("Filter Layers", script);
                                            script.audioSubscriptions[i].filterLayers = filterLayers;
                                            EditorUtility.SetDirty(script);
                                        }
                                        EditorGUILayout.LabelField("Filter Layers:", GUILayout.Width(110f));

                                        GUI.enabled = filterLayers;
                                        int layerMask = script.audioSubscriptions[i].layerMask;
                                        layerMask = EditorGUILayout.LayerField(layerMask, GUILayout.ExpandWidth(true));
                                        if (layerMask != script.audioSubscriptions[i].layerMask)
                                        {
                                            SoundManagerEditorTools.RegisterObjectChange("Change Layer Filter", script);
                                            script.audioSubscriptions[i].layerMask = layerMask;
                                            EditorUtility.SetDirty(script);
                                        }
                                        GUI.enabled = true;

                                        EditorGUILayout.EndHorizontal();


                                        //names
                                        EditorGUILayout.BeginHorizontal();

                                        bool filterNames = script.audioSubscriptions[i].filterNames;
                                        filterNames = EditorGUILayout.Toggle(filterNames, GUILayout.Width(40f));
                                        if (filterNames != script.audioSubscriptions[i].filterNames)
                                        {
                                            SoundManagerEditorTools.RegisterObjectChange("Filter Names", script);
                                            script.audioSubscriptions[i].filterNames = filterNames;
                                            EditorUtility.SetDirty(script);
                                        }

                                        EditorGUILayout.LabelField("Filter Names:", GUILayout.Width(110f));

                                        GUI.enabled = filterNames;
                                        int nameMask = script.audioSubscriptions[i].nameMask;
                                        nameMask = EditorGUILayout.MaskField(nameMask, script.audioSubscriptions[i].allNames.ToArray(), GUILayout.ExpandWidth(true));
                                        if (nameMask != script.audioSubscriptions[i].nameMask)
                                        {
                                            SoundManagerEditorTools.RegisterObjectChange("Change Name Filter", script);
                                            script.audioSubscriptions[i].nameMask = nameMask;
                                            script.audioSubscriptions[i].names.Clear();
                                            for (int n = 0; n < script.audioSubscriptions[i].allNames.Count; n++)
                                            {
                                                if ((nameMask & 1 << n) != 0)
                                                {
                                                    script.audioSubscriptions[i].names.Add(script.audioSubscriptions[i].allNames[n]);
                                                }
                                            }
                                            EditorUtility.SetDirty(script);
                                        }
                                        GUI.enabled = true;

                                        EditorGUILayout.EndHorizontal();

                                        if (filterNames)
                                        {
                                            EditorGUI.indentLevel += 2;
                                            {
                                                EditorGUILayout.BeginHorizontal();

                                                script.audioSubscriptions[i].nameToAdd = EditorGUILayout.TextField(script.audioSubscriptions[i].nameToAdd);
                                                if (GUILayout.Button("Add Name"))
                                                {
                                                    if (!string.IsNullOrEmpty(script.audioSubscriptions[i].nameToAdd) && !script.audioSubscriptions[i].names.Contains(script.audioSubscriptions[i].nameToAdd))
                                                    {
                                                        SoundManagerEditorTools.RegisterObjectChange("Add Name Filter", script);
                                                        script.audioSubscriptions[i].allNames.Add(script.audioSubscriptions[i].nameToAdd);
                                                        script.audioSubscriptions[i].nameToAdd = "";
                                                        GUIUtility.keyboardControl             = 0;
                                                        EditorUtility.SetDirty(script);
                                                    }
                                                }
                                                if (GUILayout.Button("Clear Names"))
                                                {
                                                    SoundManagerEditorTools.RegisterObjectChange("Clear Name Filter", script);
                                                    script.audioSubscriptions[i].allNames.Clear();
                                                    script.audioSubscriptions[i].names.Clear();
                                                    EditorUtility.SetDirty(script);
                                                }
                                                EditorGUILayout.EndHorizontal();
                                            }
                                            EditorGUI.indentLevel -= 2;
                                        }
                                    }
                                    EditorGUI.indentLevel -= 2;
                                }
                            }
                            if (sourceComponent != null && sourceComponentMembersArray.Length - numStandardEvents == 1)
                            {
                                EditorGUILayout.HelpBox("There are no compatible custom events on this Component. Only void parameterless events are allowed.", MessageType.None);
                            }
                            AudioSourceAction actionType = script.audioSubscriptions[i].actionType;
                            actionType = (AudioSourceAction)EditorGUILayout.EnumPopup("AudioSource Action", actionType);
                            if (actionType != script.audioSubscriptions[i].actionType)
                            {
                                SoundManagerEditorTools.RegisterObjectChange("Change AudioSource Action", script);
                                script.audioSubscriptions[i].actionType = actionType;
                                EditorUtility.SetDirty(script);
                            }
                            if (actionType == AudioSourceAction.PlayCapped)
                            {
                                string cappedName = script.audioSubscriptions[i].cappedName;
                                cappedName = EditorGUILayout.TextField("Cap ID", cappedName);
                                if (cappedName != script.audioSubscriptions[i].cappedName)
                                {
                                    SoundManagerEditorTools.RegisterObjectChange("Change Cap ID", script);
                                    script.audioSubscriptions[i].cappedName = cappedName;
                                    EditorUtility.SetDirty(script);
                                }
                            }
                        }
                    }
                    EditorGUILayout.EndVertical();
                }
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Add Event Trigger"))
                {
                    AddEvent();
                }
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();
        }
        #endregion
    }
Ejemplo n.º 22
0
    private void ShowIndividualSFXAtIndex(int i, string[] groups, GUIContent expandContent)
    {
        if (i >= script.storedSFXs.Count)
        {
            return;
        }
        AudioClip obj = script.storedSFXs[i];

        if (obj != null)
        {
            EditorGUILayout.BeginHorizontal();
            {
                AudioClip newClip = (AudioClip)EditorGUILayout.ObjectField(obj, typeof(AudioClip), false);
                if (newClip != obj)
                {
                    if (newClip == null)
                    {
                        RemoveSFX(i);
                        return;
                    }
                    else
                    {
                        SoundManagerEditorTools.RegisterObjectChange("Change SFX", script);
                        obj = newClip;
                        EditorUtility.SetDirty(script);
                    }
                }
                if ((script.showSFXDetails[i] && GUILayout.Button("-", GUILayout.Width(30f))) || (!script.showSFXDetails[i] && GUILayout.Button(expandContent, GUILayout.Width(30f))))
                {
                    script.showSFXDetails[i] = !script.showSFXDetails[i];
                }

                GUI.color = Color.red;
                if (GUILayout.Button("X", GUILayout.Width(20f)))
                {
                    RemoveSFX(i);
                    return;
                }
                GUI.color = Color.white;
            }
            EditorGUILayout.EndHorizontal();

            if (script.showSFXDetails[i])
            {
                EditorGUI.indentLevel += 4;
                string clipName = obj.name;
                int    oldIndex = IndexOfKey(clipName);
                if (oldIndex >= 0)                // if in a group, find index
                {
                    oldIndex = IndexOfGroup(script.clipToGroupValues[oldIndex]);
                }
                if (oldIndex < 0)                // if not in a group, set it to none
                {
                    oldIndex = 0;
                }
                else                 //if in a group, add 1 to index to cover for None group type
                {
                    oldIndex++;
                }

                int newIndex = EditorGUILayout.Popup("Group:", oldIndex, groups, EditorStyles.popup);
                if (oldIndex != newIndex)
                {
                    string groupName = groups[newIndex];
                    ChangeGroup(clipName, oldIndex, newIndex, groupName);
                    return;
                }

                int prepoolAmount = script.sfxPrePoolAmounts[i];

                prepoolAmount = EditorGUILayout.IntField("Prepool Amount:", prepoolAmount);
                if (prepoolAmount != script.sfxPrePoolAmounts[i])
                {
                    SoundManagerEditorTools.RegisterObjectChange("Change Prepool Amount", script);
                    script.sfxPrePoolAmounts[i] = prepoolAmount;
                    EditorUtility.SetDirty(script);
                }
                EditorGUI.indentLevel -= 4;
            }
        }
    }