Ejemplo n.º 1
0
    // returns nodes for all AudioEventGroups of the given component which are in use and contain actions
    static IEnumerable <AudioEventGroupNode> GetGroupNodes(EventSounds esComponent)
    {
        var customGroupNodes = esComponent.userDefinedSounds.Select(
            element => new AudioEventGroupNode()
        {
            type     = 0,
            group    = element,
            useGroup = true,
            name     = "Custom event\n" + element.customEventName
        }
            );

        var componentGroups = GetNamedEventGroupNodes(esComponent).Concat(customGroupNodes);

        foreach (var node in componentGroups)
        {
            if (!node.useGroup)
            {
                continue;
            }
            if (!GetAudioEvents(node.group).Any())
            {
                continue;
            }

            yield return(node);
        }
    }
Ejemplo n.º 2
0
 public void PlaySound(string clipName)
 {
     if (eventSoundsDictionary.ContainsKey(clipName))
     {
         EventSounds playSound = eventSoundsDictionary[clipName];
         playSound.audioSource.Play();
     }
 }
Ejemplo n.º 3
0
        public void PlaySound(EventSounds eventSound)
        {
            SoundEffectInstance soundEffectInstance = SoundBank[eventSound].CreateInstance();

            soundEffectInstance.IsLooped = false;
            soundEffectInstance.Volume   = _volume;
            if (eventSound == EventSounds.Die || eventSound == EventSounds.PipeTravel || eventSound == EventSounds.GameOver)
            {
                MediaPlayer.Pause();
            }
            soundEffectInstance.Play();
        }
Ejemplo n.º 4
0
 // returns nodes for all AudioEventGroups of the given component which are in use
 static IEnumerable <AudioEventGroupNode> GetNamedEventGroupNodes(EventSounds es)
 {
     return(namedEventGroups
            .Select(
                item => new AudioEventGroupNode()
     {
         type = item.type,
         group = item.getGroup(es),
         useGroup = item.useGroup(es),
         name = item.name
     }
                ));
 }
    private bool RenderAudioEvent(AudioEvent aEvent, EventSounds.EventType eType)
    {
        bool showLayerTagFilter = EventSounds.layerTagFilterEvents.Contains(eType.ToString());

        bool isDirty = false;

        EditorGUI.indentLevel = 0;

        if (eType == EventSounds.EventType.OnEnable) {
            GUIHelper.ShowColorWarning("*If this prefab is in the scene at startup, use Start event instead.");
        }

        var newSoundType = (MasterAudio.EventSoundFunctionType) EditorGUILayout.EnumPopup("Action Type", aEvent.currentSoundFunctionType);
        if (newSoundType != aEvent.currentSoundFunctionType) {
            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Action Type");
            aEvent.currentSoundFunctionType = newSoundType;
        }

        switch (aEvent.currentSoundFunctionType) {
            case MasterAudio.EventSoundFunctionType.PlaySound:
                if (maInScene) {
                    var existingIndex = groupNames.IndexOf(aEvent.soundType);

                    int? groupIndex = null;

                    EditorGUI.indentLevel = 1;

                    if (existingIndex >= 1) {
                        groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray());
                        if (existingIndex == 1) {
                            GUIHelper.ShowColorWarning("*No Sound Group specified. Event will do nothing.");
                        }
                    } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NO_GROUP_NAME) {
                        groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray());
                    } else { // non-match
                        GUIHelper.ShowColorWarning("Sound Group found no match. Type in or choose one.");
                        var newSound = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                        if (newSound != aEvent.soundType) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
                            aEvent.soundType = newSound;
                        }

                        var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, groupNames.ToArray());
                        if (newIndex >= 0) {
                            groupIndex = newIndex;
                        }
                    }

                    if (groupIndex.HasValue) {
                        if (existingIndex != groupIndex.Value) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
                        }
                        if (groupIndex.Value == -1) {
                            aEvent.soundType = MasterAudio.NO_GROUP_NAME;
                        } else {
                            aEvent.soundType = groupNames[groupIndex.Value];
                        }
                    }
                } else {
                    var newSType = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                    if (newSType != aEvent.soundType) {
                        UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
                        aEvent.soundType = newSType;
                    }
                }

                var newVarType = (EventSounds.VariationType) EditorGUILayout.EnumPopup("Variation Mode", aEvent.variationType);
                if (newVarType != aEvent.variationType) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Variation Mode");
                    aEvent.variationType = newVarType;
                }

                if (aEvent.variationType == EventSounds.VariationType.PlaySpecific) {
                    var newVarName = EditorGUILayout.TextField("Variation Name", aEvent.variationName);
                    if (newVarName != aEvent.variationName) {
                        UndoHelper.RecordObjectPropertyForUndo(sounds, "change Variation Name");
                        aEvent.variationName = newVarName;
                    }

                    if (string.IsNullOrEmpty(aEvent.variationName)) {
                        GUIHelper.ShowColorWarning("*Variation Name is empty. No sound will play.");
                    }
                }

                var newVol = EditorGUILayout.Slider("Volume", aEvent.volume, 0f, 1f);
                if (newVol != aEvent.volume) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Volume");
                    aEvent.volume = newVol;
                }

                var newFixedPitch = EditorGUILayout.Toggle("Override pitch?", aEvent.useFixedPitch);
                if (newFixedPitch != aEvent.useFixedPitch) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Override pitch");
                    aEvent.useFixedPitch = newFixedPitch;
                }
                if (aEvent.useFixedPitch) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Pitch");
                    aEvent.pitch = EditorGUILayout.Slider("Pitch", aEvent.pitch, -3f, 3f);
                }

                var newDelay = EditorGUILayout.Slider("Delay Sound (sec)", aEvent.delaySound, 0f, 10f);
                if (newDelay != aEvent.delaySound) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Delay Sound");
                    aEvent.delaySound = newDelay;
                }
                break;
            case MasterAudio.EventSoundFunctionType.PlaylistControl:
                var newPlaylistCmd = (MasterAudio.PlaylistCommand) EditorGUILayout.EnumPopup("Playlist Command", aEvent.currentPlaylistCommand);
                if (newPlaylistCmd != aEvent.currentPlaylistCommand) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Command");
                    aEvent.currentPlaylistCommand = newPlaylistCmd;
                }

                EditorGUI.indentLevel = 1;

                if (aEvent.currentPlaylistCommand != MasterAudio.PlaylistCommand.None) {
                    // show Playlist Controller dropdown
                    if (EventSounds.playlistCommandsWithAll.Contains(aEvent.currentPlaylistCommand)) {
                        var newAllControllers = EditorGUILayout.Toggle("All Playlist Controllers?", aEvent.allPlaylistControllersForGroupCmd);
                        if (newAllControllers != aEvent.allPlaylistControllersForGroupCmd) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle All Playlist Controllers");
                            aEvent.allPlaylistControllersForGroupCmd = newAllControllers;
                        }
                    }

                    if (!aEvent.allPlaylistControllersForGroupCmd) {
                        if (playlistControllerNames.Count > 0) {
                            var existingIndex = playlistControllerNames.IndexOf(aEvent.playlistControllerName);

                            int? playlistControllerIndex = null;

                            if (existingIndex >= 1) {
                                playlistControllerIndex = EditorGUILayout.Popup("Playlist Controller", existingIndex, playlistControllerNames.ToArray());
                                if (existingIndex == 1) {
                                    GUIHelper.ShowColorWarning("*No Playlist Controller specified. Event will do nothing.");
                                }
                            }  else if (existingIndex == -1 && aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) {
                                playlistControllerIndex = EditorGUILayout.Popup("Playlist Controller", existingIndex, playlistControllerNames.ToArray());
                            } else { // non-match
                                GUIHelper.ShowColorWarning("Playlist Controller found no match. Type in or choose one.");

                                var newPlaylistController = EditorGUILayout.TextField("Playlist Controller", aEvent.playlistControllerName);
                                if (newPlaylistController != aEvent.playlistControllerName) {
                                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Controller");
                                    aEvent.playlistControllerName = newPlaylistController;
                                }
                                var newIndex = EditorGUILayout.Popup("All Playlist Controllers", -1, playlistControllerNames.ToArray());
                                if (newIndex >= 0) {
                                    playlistControllerIndex = newIndex;
                                }
                            }

                            if (playlistControllerIndex.HasValue) {
                                if (existingIndex != playlistControllerIndex.Value) {
                                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Controller");
                                }
                                if (playlistControllerIndex.Value == -1) {
                                    aEvent.playlistControllerName = MasterAudio.NO_GROUP_NAME;
                                } else {
                                    aEvent.playlistControllerName = playlistControllerNames[playlistControllerIndex.Value];
                                }
                            }
                        } else {
                            var newPlaylistControllerName = EditorGUILayout.TextField("Playlist Controller", aEvent.playlistControllerName);
                            if (newPlaylistControllerName != aEvent.playlistControllerName) {
                                UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Controller");
                                aEvent.playlistControllerName = newPlaylistControllerName;
                            }
                        }
                    }
                }

                switch (aEvent.currentPlaylistCommand) {
                    case MasterAudio.PlaylistCommand.ChangePlaylist:
                        // show playlist name dropdown
                        if (maInScene) {
                            var existingIndex = playlistNames.IndexOf(aEvent.playlistName);

                            int? playlistIndex = null;

                            if (existingIndex >= 1) {
                                playlistIndex = EditorGUILayout.Popup("Playlist Name", existingIndex, playlistNames.ToArray());
                                if (existingIndex == 1) {
                                    GUIHelper.ShowColorWarning("*No Playlist Name specified. Event will do nothing.");
                                }
                            } else if (existingIndex == -1 && aEvent.playlistName == MasterAudio.NO_GROUP_NAME) {
                                playlistIndex = EditorGUILayout.Popup("Playlist Name", existingIndex, playlistNames.ToArray());
                            } else { // non-match
                                GUIHelper.ShowColorWarning("Playlist Name found no match. Type in or choose one.");

                                var newPlaylist = EditorGUILayout.TextField("Playlist Name", aEvent.playlistName);
                                if (newPlaylist != aEvent.playlistName) {
                                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Name");
                                    aEvent.playlistName = newPlaylist;
                                }
                                var newIndex = EditorGUILayout.Popup("All Playlists", -1, playlistNames.ToArray());
                                if (newIndex >= 0) {
                                    playlistIndex = newIndex;
                                }
                            }

                            if (playlistIndex.HasValue) {
                                if (existingIndex != playlistIndex.Value) {
                                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Name");
                                }
                                if (playlistIndex.Value == -1) {
                                    aEvent.playlistName = MasterAudio.NO_GROUP_NAME;
                                } else {
                                    aEvent.playlistName = playlistNames[playlistIndex.Value];
                                }
                            }
                        } else {
                            var newPlaylistName = EditorGUILayout.TextField("Playlist Name", aEvent.playlistName);
                            if (newPlaylistName != aEvent.playlistName) {
                                UndoHelper.RecordObjectPropertyForUndo(sounds, "change Playlist Name");
                                aEvent.playlistName = newPlaylistName;
                            }
                        }

                        var newStartPlaylist = EditorGUILayout.Toggle("Start Playlist?", aEvent.startPlaylist);
                        if (newStartPlaylist != aEvent.startPlaylist) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Start Playlist");
                            aEvent.startPlaylist = newStartPlaylist;
                        }
                        break;
                    case MasterAudio.PlaylistCommand.FadeToVolume:
                        var newFadeVol = EditorGUILayout.Slider("Target Volume", aEvent.fadeVolume, 0f, 1f);
                        if (newFadeVol != aEvent.fadeVolume) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Target Volume");
                            aEvent.fadeVolume = newFadeVol;
                        }

                        var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                        if (newFadeTime != aEvent.fadeTime) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Fade Time");
                            aEvent.fadeTime = newFadeTime;
                        }
                        break;
                    case MasterAudio.PlaylistCommand.PlayClip:
                        var newClip = EditorGUILayout.TextField("Clip Name", aEvent.clipName);
                        if (newClip != aEvent.clipName) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Clip Name");
                            aEvent.clipName = newClip;
                        }
                        if (string.IsNullOrEmpty(aEvent.clipName)) {
                            GUIHelper.ShowColorWarning("*Clip name is empty. Event will do nothing.");
                        }
                        break;
                }
                break;
            case MasterAudio.EventSoundFunctionType.GroupControl:
                EditorGUI.indentLevel = 1;

                var newGroupCmd = (MasterAudio.SoundGroupCommand) EditorGUILayout.EnumPopup("Group Command", aEvent.currentSoundGroupCommand);
                if (newGroupCmd != aEvent.currentSoundGroupCommand) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Group Command");
                    aEvent.currentSoundGroupCommand = newGroupCmd;
                }

                if (aEvent.currentSoundGroupCommand != MasterAudio.SoundGroupCommand.None) {
                    var newAllTypes = EditorGUILayout.Toggle("Do For Every Group?", aEvent.allSoundTypesForGroupCmd);
                    if (newAllTypes != aEvent.allSoundTypesForGroupCmd) {
                        UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Do For Every Group?");
                        aEvent.allSoundTypesForGroupCmd = newAllTypes;
                    }

                    if (!aEvent.allSoundTypesForGroupCmd) {
                        if (maInScene) {
                            var existingIndex = groupNames.IndexOf(aEvent.soundType);

                            int? groupIndex = null;

                            if (existingIndex >= 1) {
                                groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray());
                            } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NO_GROUP_NAME) {
                                groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray());
                            } else { // non-match
                                GUIHelper.ShowColorWarning("Sound Group found no match. Type in or choose one.");

                                var newSType = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                if (newSType != aEvent.soundType) {
                                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
                                    aEvent.soundType = newSType;
                                }
                                var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, groupNames.ToArray());
                                if (newIndex >= 0) {
                                    groupIndex = newIndex;
                                }
                            }

                            if (groupIndex.HasValue) {
                                if (existingIndex != groupIndex.Value) {
                                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
                                }
                                if (groupIndex.Value == -1) {
                                    aEvent.soundType = MasterAudio.NO_GROUP_NAME;
                                } else {
                                    aEvent.soundType = groupNames[groupIndex.Value];
                                }
                            }
                        } else {
                            var newSoundT = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                            if (newSoundT != aEvent.soundType) {
                                UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Group");
                                aEvent.soundType = newSoundT;
                            }
                        }
                    }
                }

                switch (aEvent.currentSoundGroupCommand) {
                    case MasterAudio.SoundGroupCommand.None:
                        break;
                    case MasterAudio.SoundGroupCommand.FadeToVolume:
                        var newFadeVol = EditorGUILayout.Slider("Target Volume", aEvent.fadeVolume, 0f, 1f);
                        if (newFadeVol != aEvent.fadeVolume) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Target Volume");
                            aEvent.fadeVolume = newFadeVol;
                        }

                        var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                        if (newFadeTime != aEvent.fadeTime) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Fade Time");
                            aEvent.fadeTime = newFadeTime;
                        }
                        break;
                    case MasterAudio.SoundGroupCommand.FadeOutAllOfSound:
                        var newFadeT = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                        if (newFadeT != aEvent.fadeTime) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Fade Time");
                            aEvent.fadeTime = newFadeT;
                        }
                        break;
                    case MasterAudio.SoundGroupCommand.Mute:
                        break;
                    case MasterAudio.SoundGroupCommand.Pause:
                        break;
                    case MasterAudio.SoundGroupCommand.Solo:
                        break;
                    case MasterAudio.SoundGroupCommand.Unmute:
                        break;
                    case MasterAudio.SoundGroupCommand.Unpause:
                        break;
                    case MasterAudio.SoundGroupCommand.Unsolo:
                        break;
                }

                break;
            case MasterAudio.EventSoundFunctionType.BusControl:
                var newBusCmd = (MasterAudio.BusCommand) EditorGUILayout.EnumPopup("Bus Command", aEvent.currentBusCommand);
                if (newBusCmd != aEvent.currentBusCommand) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Bus Command");
                    aEvent.currentBusCommand = newBusCmd;
                }

                EditorGUI.indentLevel = 1;

                if (aEvent.currentBusCommand != MasterAudio.BusCommand.None) {
                    var newAllTypes = EditorGUILayout.Toggle("Do For Every Bus?", aEvent.allSoundTypesForBusCmd);
                    if (newAllTypes != aEvent.allSoundTypesForBusCmd) {
                        UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Do For Every Bus?");
                        aEvent.allSoundTypesForBusCmd = newAllTypes;
                    }

                    if (!aEvent.allSoundTypesForBusCmd) {
                        if (maInScene) {
                            var existingIndex = busNames.IndexOf(aEvent.busName);

                            int? busIndex = null;

                            if (existingIndex >= 1) {
                                busIndex = EditorGUILayout.Popup("Bus Name", existingIndex, busNames.ToArray());
                                if (existingIndex == 1) {
                                    GUIHelper.ShowColorWarning("*No Bus Name specified. Event will do nothing.");
                                }
                            } else if (existingIndex == -1 && aEvent.busName == MasterAudio.NO_GROUP_NAME) {
                                busIndex = EditorGUILayout.Popup("Bus Name", existingIndex, busNames.ToArray());
                            } else { // non-match
                                var newBusName = EditorGUILayout.TextField("Bus Name", aEvent.busName);
                                if (newBusName != aEvent.busName) {
                                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Bus Name");
                                    aEvent.busName = newBusName;
                                }

                                var newIndex = EditorGUILayout.Popup("All Buses", -1, busNames.ToArray());
                                if (newIndex >= 0) {
                                    busIndex = newIndex;
                                }
                                GUIHelper.ShowColorWarning("*Bus Name found no match. Type in or choose one.");
                            }

                            if (busIndex.HasValue) {
                                if (existingIndex != busIndex.Value) {
                                    UndoHelper.RecordObjectPropertyForUndo(sounds, "change Bus");
                                }
                                if (busIndex.Value == -1) {
                                    aEvent.busName = MasterAudio.NO_GROUP_NAME;
                                } else {
                                    aEvent.busName = busNames[busIndex.Value];
                                }
                            }
                        } else {
                            var newBusName = EditorGUILayout.TextField("Bus Name", aEvent.busName);
                            if (newBusName != aEvent.busName) {
                                UndoHelper.RecordObjectPropertyForUndo(sounds, "change Bus Name");
                                aEvent.busName = newBusName;
                            }
                        }
                    }

                    var newVolume = EditorGUILayout.Slider("Volume", aEvent.volume, 0f, 1f);
                    if (newVolume != aEvent.volume) {
                        UndoHelper.RecordObjectPropertyForUndo(sounds, "change Volume");
                        aEvent.volume = newVolume;
                    }

                    var newFixPitch = EditorGUILayout.Toggle("Override pitch?", aEvent.useFixedPitch);
                    if (newFixPitch != aEvent.useFixedPitch) {
                        UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Override pitch");
                        aEvent.useFixedPitch = newFixPitch;
                    }
                    if (aEvent.useFixedPitch) {
                        GUIHelper.ShowColorWarning("*Random pitches for the variation will not be used.");
                        var newPitch = EditorGUILayout.Slider("Pitch", aEvent.pitch, -3f, 3f);
                        if (newPitch != aEvent.pitch) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Pitch");
                            aEvent.pitch = newPitch;
                        }
                    }
                }

                switch (aEvent.currentBusCommand) {
                    case MasterAudio.BusCommand.FadeToVolume:
                        var newFadeVol = EditorGUILayout.Slider("Target Volume", aEvent.fadeVolume, 0f, 1f);
                        if (newFadeVol != aEvent.fadeVolume) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Target Volume");
                            aEvent.fadeVolume = newFadeVol;
                        }

                        var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                        if (newFadeTime != aEvent.fadeTime) {
                            UndoHelper.RecordObjectPropertyForUndo(sounds, "change Fade Time");
                            aEvent.fadeTime = newFadeTime;
                        }
                        break;
                    case MasterAudio.BusCommand.Pause:
                        break;
                    case MasterAudio.BusCommand.Unpause:
                        break;
                }

                break;
        }

        EditorGUI.indentLevel = 0;

        var newEmit = EditorGUILayout.Toggle("Emit Particle", aEvent.emitParticles);
        if (newEmit != aEvent.emitParticles) {
            UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Emit Particle");
            aEvent.emitParticles = newEmit;
        }
        if (aEvent.emitParticles) {
            var newParticleCount = EditorGUILayout.IntSlider("Particle Count", aEvent.particleCountToEmit, 1, 100);
            if (newParticleCount != aEvent.particleCountToEmit) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "change Particle Count");
                aEvent.particleCountToEmit = newParticleCount;
            }
        }

        if (showLayerTagFilter) {
            var newUseLayers = EditorGUILayout.BeginToggleGroup("Layer filters", aEvent.useLayerFilter);
            if (newUseLayers != aEvent.useLayerFilter) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Layer filters");
                aEvent.useLayerFilter = newUseLayers;
            }
            if (aEvent.useLayerFilter) {
                for (var i = 0; i < aEvent.matchingLayers.Count; i++) {
                    var newLayer = EditorGUILayout.LayerField("Layer Match " + (i + 1), aEvent.matchingLayers[i]);
                    if (newLayer != aEvent.matchingLayers[i]) {
                        UndoHelper.RecordObjectPropertyForUndo(sounds, "change Layer filter");
                        aEvent.matchingLayers[i] = newLayer;
                    }
                }
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(24);

                if (GUILayout.Button(new GUIContent("Add", "Click to add a layer match at the end"), GUILayout.Width(60))) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "add Layer filter");
                    aEvent.matchingLayers.Add(0);
                    isDirty = true;
                }
                if (aEvent.matchingLayers.Count > 1) {
                    if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last layer match"), GUILayout.Width(60))) {
                        UndoHelper.RecordObjectPropertyForUndo(sounds, "remove Layer filter");
                        aEvent.matchingLayers.RemoveAt(aEvent.matchingLayers.Count - 1);
                        isDirty = true;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();

            var newTagFilter = EditorGUILayout.BeginToggleGroup("Tag filter", aEvent.useTagFilter);
            if (newTagFilter != aEvent.useTagFilter) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Tag filter");
                aEvent.useTagFilter = newTagFilter;
            }

            if (aEvent.useTagFilter) {
                for (var i = 0; i < aEvent.matchingTags.Count; i++) {
                    var newTag = EditorGUILayout.TagField("Tag Match " + (i + 1), aEvent.matchingTags[i]);
                    if (newTag != aEvent.matchingTags[i]) {
                        UndoHelper.RecordObjectPropertyForUndo(sounds, "change Tag filter");
                        aEvent.matchingTags[i] = newTag;
                    }
                }
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(24);
                if (GUILayout.Button(new GUIContent("Add", "Click to add a tag match at the end"), GUILayout.Width(60))) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "Add Tag filter");
                    aEvent.matchingTags.Add("Untagged");
                    isDirty = true;
                }
                if (aEvent.matchingTags.Count > 1) {
                    if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last tag match"), GUILayout.Width(60))) {
                        UndoHelper.RecordObjectPropertyForUndo(sounds, "remove Tag filter");
                        aEvent.matchingTags.RemoveAt(aEvent.matchingLayers.Count - 1);
                        isDirty = true;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();
        }

        return isDirty;
    }
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls();

        ma = MasterAudio.Instance;
        if (ma != null) {
            GUIHelper.ShowHeaderTexture(ma.logoTexture);
        }

        sounds = (EventSounds)target;

        maInScene = ma != null;
        if (maInScene) {
            groupNames = ma.GroupNames;
            busNames = ma.BusNames;
            playlistNames = ma.PlaylistNames;
        }

        playlistControllerNames = new List<string>();
        playlistControllerNames.Add(MasterAudio.DYNAMIC_GROUP_NAME);
        playlistControllerNames.Add(MasterAudio.NO_GROUP_NAME);

        var pcs = GameObject.FindObjectsOfType(typeof(PlaylistController));
        for (var i = 0; i < pcs.Length; i++) {
            playlistControllerNames.Add(pcs[i].name);
        }

        // populate unused Events for dropdown
        var unusedEventTypes = new List<string>();
        if (!sounds.useStartSound) {
            unusedEventTypes.Add("Start");
        }
        if (!sounds.useEnableSound) {
            unusedEventTypes.Add("Enable");
        }
        if (!sounds.useDisableSound) {
            unusedEventTypes.Add("Disable");
        }
        if (!sounds.useVisibleSound) {
            unusedEventTypes.Add("Visible");
        }
        if (!sounds.useInvisibleSound) {
            unusedEventTypes.Add("Invisible");
        }

        #if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
            // these events don't exist
        #else
            if (!sounds.useCollision2dSound) {
                unusedEventTypes.Add("2D Collision");
            }
            if (!sounds.useTriggerEnter2dSound) {
                unusedEventTypes.Add("2D Trigger Enter");
            }
            if (!sounds.useTriggerExit2dSound) {
                unusedEventTypes.Add("2D Trigger Exit");
            }
        #endif

        if (!sounds.useCollisionSound) {
            unusedEventTypes.Add("Collision");
        }
        if (!sounds.useTriggerEnterSound) {
            unusedEventTypes.Add("Trigger Enter");
        }
        if (!sounds.useTriggerExitSound) {
            unusedEventTypes.Add("Trigger Exit");
        }
        if (!sounds.useParticleCollisionSound) {
            unusedEventTypes.Add("Particle Collision");
        }
        if (!sounds.useMouseEnterSound) {
            unusedEventTypes.Add("Mouse Enter");
        }
        if (!sounds.useMouseClickSound) {
            unusedEventTypes.Add("Mouse Click");
        }
        if (!sounds.useSpawnedSound && sounds.showPoolManager) {
            unusedEventTypes.Add("Spawned");
        }
        if (!sounds.useDespawnedSound && sounds.showPoolManager) {
            unusedEventTypes.Add("Despawned");
        }

        var newDisable = EditorGUILayout.Toggle("Disable Sounds", sounds.disableSounds);
        if (newDisable != sounds.disableSounds) {
            UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Disable Sounds");
            sounds.disableSounds = newDisable;
        }

        if (!sounds.disableSounds) {
            var newSpawnMode = (MasterAudio.SoundSpawnLocationMode) EditorGUILayout.EnumPopup("Sound Spawn Mode", sounds.soundSpawnMode);
            if (newSpawnMode != sounds.soundSpawnMode) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "change Sound Spawn Mode");
                sounds.soundSpawnMode = newSpawnMode;
            }

            var newGiz = EditorGUILayout.Toggle("Show 3D Gizmo", sounds.showGizmo);
            if (newGiz != sounds.showGizmo) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Show 3D Gizmo");
                sounds.showGizmo = newGiz;
            }

            var newPM = EditorGUILayout.Toggle("PoolManager Events", sounds.showPoolManager);
            if (newPM != sounds.showPoolManager) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle PoolManager Events");
                sounds.showPoolManager = newPM;
            }

            var newUnused = EditorGUILayout.Toggle("Minimal Mode", sounds.hideUnused);
            if (newUnused != sounds.hideUnused) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Hide Unused Events");
                sounds.hideUnused = newUnused;
            }

            if (sounds.hideUnused) {
                var newEventIndex = EditorGUILayout.Popup("Event To Activate", -1, unusedEventTypes.ToArray());
                if (newEventIndex > -1) {
                    var selectedEvent = unusedEventTypes[newEventIndex];
                    switch (selectedEvent) {
                        case "Start":
                            sounds.useStartSound = true;
                            break;
                        case "Enable":
                            sounds.useEnableSound = true;
                            break;
                        case "Disable":
                            sounds.useDisableSound = true;
                            break;
                        case "Visible":
                            sounds.useVisibleSound = true;
                            break;
                        case "Invisible":
                            sounds.useInvisibleSound = true;
                            break;
                        case "2D Collision":
                            sounds.useCollision2dSound = true;
                            break;
                        case "2D Trigger Enter":
                            sounds.useTriggerEnter2dSound = true;
                            break;
                        case "2D Trigger Exit":
                            sounds.useTriggerExit2dSound = true;
                            break;
                        case "Collision":
                            sounds.useCollisionSound = true;
                            break;
                        case "Trigger Enter":
                            sounds.useTriggerEnterSound = true;
                            break;
                        case "Trigger Exit":
                            sounds.useTriggerExitSound = true;
                            break;
                        case "Particle Collision":
                            sounds.useParticleCollisionSound = true;
                            break;
                        case "Mouse Enter":
                            sounds.useMouseEnterSound = true;
                            break;
                        case "Mouse Click":
                            sounds.useMouseClickSound = true;
                            break;
                        case "Spawned":
                            sounds.useSpawnedSound = true;
                            break;
                        case "Despawned":
                            sounds.useDespawnedSound = true;
                            break;
                    }
                }
            }
        }

        EditorGUILayout.Separator();
        var suffix = string.Empty;
        if (sounds.disableSounds) {
            suffix = " (DISABLED)";
        } else if (unusedEventTypes.Count > 0 && sounds.hideUnused) {
            suffix = " (" + unusedEventTypes.Count + " hidden)";
        }
        GUILayout.Label("Sound Triggers" + suffix, EditorStyles.boldLabel);

        var disabledText = "";
        if (sounds.disableSounds) {
            disabledText = " (DISABLED) ";
        }

        List<bool> changedList = new List<bool>();

        // trigger sounds
        if (!sounds.hideUnused || sounds.useStartSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);

            var newUseStart = EditorGUILayout.Toggle("Start" + disabledText, sounds.useStartSound);
            if (newUseStart != sounds.useStartSound) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Start Sound");
                sounds.useStartSound = newUseStart;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useStartSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.startSound, EventSounds.EventType.OnStart));
            }
        }

        if (!sounds.hideUnused || sounds.useEnableSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newUseEnable = EditorGUILayout.Toggle("Enable" + disabledText, sounds.useEnableSound);
            if (newUseEnable != sounds.useEnableSound) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Enable Sound");
                sounds.useEnableSound = newUseEnable;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useEnableSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.enableSound, EventSounds.EventType.OnEnable));
            }
        }

        if (!sounds.hideUnused || sounds.useDisableSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newDisableSound = EditorGUILayout.Toggle("Disable" + disabledText, sounds.useDisableSound);
            if (newDisableSound != sounds.useDisableSound) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Disable Sound");
                sounds.useDisableSound = newDisableSound;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useDisableSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.disableSound, EventSounds.EventType.OnDisable));
            }
        }

        if (!sounds.hideUnused || sounds.useVisibleSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newVisible = EditorGUILayout.Toggle("Visible" + disabledText, sounds.useVisibleSound);
            if (newVisible != sounds.useVisibleSound) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Visible Sound");
                sounds.useVisibleSound = newVisible;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useVisibleSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.visibleSound, EventSounds.EventType.OnVisible));
            }
        }

        if (!sounds.hideUnused || sounds.useInvisibleSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newInvis = EditorGUILayout.Toggle("Invisible" + disabledText, sounds.useInvisibleSound);
            if (newInvis != sounds.useInvisibleSound) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Invisible Sound");
                sounds.useInvisibleSound = newInvis;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useInvisibleSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.invisibleSound, EventSounds.EventType.OnInvisible));
            }
        }

        #if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
            // these events don't exist
        #else
            if (!sounds.hideUnused || sounds.useCollision2dSound) {
                EditorGUI.indentLevel = 0;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newCollision2d = EditorGUILayout.Toggle("2D Collision" + disabledText, sounds.useCollision2dSound);
                if (newCollision2d != sounds.useCollision2dSound) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle 2D Collision Sound");
                    sounds.useCollision2dSound = newCollision2d;
                }
                EditorGUILayout.EndHorizontal();
                if (sounds.useCollision2dSound && !sounds.disableSounds) {
                    changedList.Add(RenderAudioEvent(sounds.collision2dSound, EventSounds.EventType.OnCollision2D));
                }
            }

            if (!sounds.hideUnused || sounds.useTriggerEnter2dSound) {
                EditorGUI.indentLevel = 0;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newTrigger2d = EditorGUILayout.Toggle("2D Trigger Enter" + disabledText, sounds.useTriggerEnter2dSound);
                if (newTrigger2d != sounds.useTriggerEnter2dSound) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle 2D Trigger Enter Sound");
                    sounds.useTriggerEnter2dSound = newTrigger2d;
                }
                EditorGUILayout.EndHorizontal();
                if (sounds.useTriggerEnter2dSound && !sounds.disableSounds) {
                    changedList.Add(RenderAudioEvent(sounds.triggerEnter2dSound, EventSounds.EventType.OnTriggerEnter2D));
                }
            }

            if (!sounds.hideUnused || sounds.useTriggerExit2dSound) {
                EditorGUI.indentLevel = 0;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newTriggerExit2d = EditorGUILayout.Toggle("2D Trigger Exit" + disabledText, sounds.useTriggerExit2dSound);
                if (newTriggerExit2d != sounds.useTriggerExit2dSound) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle 2D Trigger Exit Sound");
                    sounds.useTriggerExit2dSound = newTriggerExit2d;
                }
                EditorGUILayout.EndHorizontal();
                if (sounds.useTriggerExit2dSound && !sounds.disableSounds) {
                    changedList.Add(RenderAudioEvent(sounds.triggerExit2dSound, EventSounds.EventType.OnTriggerExit2D));
                }
            }
        #endif

        if (!sounds.hideUnused || sounds.useCollisionSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newCollision = EditorGUILayout.Toggle("Collision" + disabledText, sounds.useCollisionSound);
            if (newCollision != sounds.useCollisionSound) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Collision Sound");
                sounds.useCollisionSound = newCollision;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useCollisionSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.collisionSound, EventSounds.EventType.OnCollision));
            }
        }

        if (!sounds.hideUnused || sounds.useTriggerEnterSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newTrigger = EditorGUILayout.Toggle("Trigger Enter" + disabledText, sounds.useTriggerEnterSound);
            if (newTrigger != sounds.useTriggerEnterSound) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Trigger Enter Sound");
                sounds.useTriggerEnterSound = newTrigger;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useTriggerEnterSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.triggerSound, EventSounds.EventType.OnTriggerEnter));
            }
        }

        if (!sounds.hideUnused || sounds.useTriggerExitSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newTriggerExit = EditorGUILayout.Toggle("Trigger Exit" + disabledText, sounds.useTriggerExitSound);
            if (newTriggerExit != sounds.useTriggerExitSound) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Trigger Exit Sound");
                sounds.useTriggerExitSound = newTriggerExit;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useTriggerExitSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.triggerExitSound, EventSounds.EventType.OnTriggerExit));
            }
        }

        if (!sounds.hideUnused || sounds.useParticleCollisionSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newCollision = EditorGUILayout.Toggle("Particle Collision" + disabledText, sounds.useParticleCollisionSound);
            if (newCollision != sounds.useParticleCollisionSound) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Particle Collision Sound");
                sounds.useParticleCollisionSound = newCollision;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useParticleCollisionSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.particleCollisionSound, EventSounds.EventType.OnParticleCollision));
            }
        }

        if (!sounds.hideUnused || sounds.useMouseEnterSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newMouseEnter = EditorGUILayout.Toggle("Mouse Enter" + disabledText, sounds.useMouseEnterSound);
            if (newMouseEnter != sounds.useMouseEnterSound) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Mouse Enter Sound");
                sounds.useMouseEnterSound = newMouseEnter;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useMouseEnterSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.mouseEnterSound, EventSounds.EventType.OnMouseEnter));
            }
        }

        if (!sounds.hideUnused || sounds.useMouseClickSound) {
            EditorGUI.indentLevel = 0;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newMouseClick = EditorGUILayout.Toggle("Mouse Click" + disabledText, sounds.useMouseClickSound);
            if (newMouseClick != sounds.useMouseClickSound) {
                sounds.useMouseClickSound = newMouseClick;
            }
            EditorGUILayout.EndHorizontal();
            if (sounds.useMouseClickSound && !sounds.disableSounds) {
                UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Mouse Click Sound");
                changedList.Add(RenderAudioEvent(sounds.mouseClickSound, EventSounds.EventType.OnMouseClick));
            }
        }

        if (sounds.showPoolManager) {
            if (!sounds.hideUnused || sounds.useSpawnedSound) {
                EditorGUI.indentLevel = 0;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newSpawned = EditorGUILayout.Toggle("Spawned (PoolManager)" + disabledText, sounds.useSpawnedSound);
                if (newSpawned != sounds.useSpawnedSound) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Spawned Sound");
                    sounds.useSpawnedSound = newSpawned;
                }
                EditorGUILayout.EndHorizontal();
                if (sounds.useSpawnedSound && !sounds.disableSounds) {
                    changedList.Add(RenderAudioEvent(sounds.spawnedSound, EventSounds.EventType.OnSpawned));
                }
            }

            if (!sounds.hideUnused || sounds.useDespawnedSound) {
                EditorGUI.indentLevel = 0;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newDespawned = EditorGUILayout.Toggle("Despawned (PoolManager)" + disabledText, sounds.useDespawnedSound);
                if (newDespawned != sounds.useDespawnedSound) {
                    UndoHelper.RecordObjectPropertyForUndo(sounds, "toggle Despawned Sound");
                    sounds.useDespawnedSound = newDespawned;
                }
                EditorGUILayout.EndHorizontal();
                if (sounds.useDespawnedSound && !sounds.disableSounds) {
                    changedList.Add(RenderAudioEvent(sounds.despawnedSound, EventSounds.EventType.OnDespawned));
                }
            }
        }

        if (GUI.changed || changedList.Contains(true)) {
            EditorUtility.SetDirty(target);
        }

        GUIHelper.RepaintIfUndoOrRedo(this);

        //DrawDefaultInspector();
    }
Ejemplo n.º 7
0
 // ReSharper disable once UnusedMember.Local
 private void DeactivateEvent(EventSounds.EventType eType)
 {
     switch (eType) {
         case EventSounds.EventType.UnitySliderChanged:
             _sounds.useUnitySliderChangedSound = false;
             break;
         case EventSounds.EventType.UnityButtonClicked:
             _sounds.useUnityButtonClickedSound = false;
             break;
         case EventSounds.EventType.UnityPointerDown:
             _sounds.useUnityPointerDownSound = false;
             break;
         case EventSounds.EventType.UnityPointerUp:
             _sounds.useUnityPointerUpSound = false;
             break;
         case EventSounds.EventType.UnityDrag:
             _sounds.useUnityDragSound = false;
             break;
         case EventSounds.EventType.UnityDrop:
             _sounds.useUnityDropSound = false;
             break;
         case EventSounds.EventType.UnityPointerEnter:
             _sounds.useUnityPointerEnterSound = false;
             break;
         case EventSounds.EventType.UnityPointerExit:
             _sounds.useUnityPointerExitSound = false;
             break;
         case EventSounds.EventType.UnityScroll:
             _sounds.useUnityScrollSound = false;
             break;
         case EventSounds.EventType.UnityUpdateSelected:
             _sounds.useUnityUpdateSelectedSound = false;
             break;
         case EventSounds.EventType.UnitySelect:
             _sounds.useUnitySelectSound = false;
             break;
         case EventSounds.EventType.UnityDeselect:
             _sounds.useUnityDeselectSound = false;
             break;
         case EventSounds.EventType.UnityMove:
             _sounds.useUnityMoveSound = false;
             break;
         case EventSounds.EventType.UnityInitializePotentialDrag:
             _sounds.useUnityInitializePotentialDragSound = false;
             break;
         case EventSounds.EventType.UnityBeginDrag:
             _sounds.useUnityBeginDragSound = false;
             break;
         case EventSounds.EventType.UnityEndDrag:
             _sounds.useUnityEndDragSound = false;
             break;
         case EventSounds.EventType.UnitySubmit:
             _sounds.useUnitySubmitSound = false;
             break;
         case EventSounds.EventType.UnityCancel:
             _sounds.useUnityCancelSound = false;
             break;
         default:
             Debug.LogError("Add code to remove: " + eType);
             break;
     }
 }
Ejemplo n.º 8
0
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls();

        MasterAudio.Instance = null;

        _ma = MasterAudio.Instance;
        _maInScene = _ma != null;

        if (_maInScene) {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.LogoTexture);
        }

        _isDirty = false;

        DTGUIHelper.HelpHeader("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/EventSounds.htm");

        _sounds = (EventSounds)target;

        #if UNITY_4_6 || UNITY_5
        var showNewUIEvents = _sounds.unityUIMode == EventSounds.UnityUIVersion.uGUI;
        var hasSlider = _sounds.GetComponent<Slider>() != null;
        var hasButton = _sounds.GetComponent<Button>() != null;
        var hasToggle = _sounds.GetComponent<Toggle>() != null;
        var hasRect = _sounds.GetComponent<RectTransform>() != null;
        var canClick = hasRect;
        #else
        const bool showNewUIEvents = false;
        const bool hasSlider = false;
        const bool hasButton = false;
        const bool canClick = false;
        const bool hasToggle = false;
        #endif

        if (_maInScene) {
            // ReSharper disable once PossibleNullReferenceException
            _groupNames = _ma.GroupNames;
            _busNames = _ma.BusNames;
            _playlistNames = _ma.PlaylistNames;
            _customEventNames = _ma.CustomEventNames;
        }
        PopulateItemNames(_groupNames, _busNames, _playlistNames, _customEventNames);

        _playlistControllerNames = new List<string> { MasterAudio.DynamicGroupName, MasterAudio.NoGroupName };

        #if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5
        // component doesn't exist
        #else
        var anim = _sounds.GetComponent<Animator>();
        _hasMechanim = anim != null;
        #endif

        _changedList.Clear();
        var pcs = FindObjectsOfType(typeof(PlaylistController));
        foreach (var t in pcs) {
            _playlistControllerNames.Add(t.name);
        }

        // populate unused Events for dropdown
        var unusedEventTypes = new List<string>();
        if (!_sounds.useStartSound) {
            unusedEventTypes.Add("Start");
        }
        if (!_sounds.useEnableSound) {
            unusedEventTypes.Add("Enable");
        }
        if (!_sounds.useDisableSound) {
            unusedEventTypes.Add("Disable");
        }
        if (!_sounds.useVisibleSound) {
            unusedEventTypes.Add("Visible");
        }
        if (!_sounds.useInvisibleSound) {
            unusedEventTypes.Add("Invisible");
        }

        #if UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
        // these events don't exist
        #else
        if (!_sounds.useCollision2dSound) {
            unusedEventTypes.Add("2D Collision Enter");
        }
        if (!_sounds.useCollisionExit2dSound) {
            unusedEventTypes.Add("2D Collision Exit");
        }
        if (!_sounds.useTriggerEnter2dSound) {
            unusedEventTypes.Add("2D Trigger Enter");
        }
        if (!_sounds.useTriggerExit2dSound) {
            unusedEventTypes.Add("2D Trigger Exit");
        }
        #endif

        if (!_sounds.useCollisionSound) {
            unusedEventTypes.Add("Collision Enter");
        }
        if (!_sounds.useCollisionExitSound) {
            unusedEventTypes.Add("Collision Exit");
        }
        if (!_sounds.useTriggerEnterSound) {
            unusedEventTypes.Add("Trigger Enter");
        }
        if (!_sounds.useTriggerExitSound) {
            unusedEventTypes.Add("Trigger Exit");
        }
        if (!_sounds.useParticleCollisionSound) {
            unusedEventTypes.Add("Particle Collision");
        }
        if (_sounds.unityUIMode == EventSounds.UnityUIVersion.Legacy) {
            if (!_sounds.useMouseEnterSound) {
                unusedEventTypes.Add("Mouse Enter (Legacy)");
            }
            if (!_sounds.useMouseExitSound) {
                unusedEventTypes.Add("Mouse Exit (Legacy)");
            }
            if (!_sounds.useMouseClickSound) {
                unusedEventTypes.Add("Mouse Down (Legacy)");
            }
            if (!_sounds.useMouseDragSound) {
                unusedEventTypes.Add("Mouse Drag (Legacy)");
            }
            if (!_sounds.useMouseUpSound) {
                unusedEventTypes.Add("Mouse Up (Legacy)");
            }
        }

        // ReSharper disable HeuristicUnreachableCode
        #pragma warning disable 162
        // ReSharper disable once ConditionIsAlwaysTrueOrFalse
        if (showNewUIEvents) {
            if (hasSlider) {
                if (!_sounds.useUnitySliderChangedSound) {
                    unusedEventTypes.Add("Slider Changed (uGUI)");
                }
            }
            if (hasButton) {
                if (!_sounds.useUnityButtonClickedSound) {
                    unusedEventTypes.Add("Button Click (uGUI)");
                }
            }

            if (hasToggle) {
                if (!_sounds.useUnityToggleSound) {
                    unusedEventTypes.Add("Toggle (uGUI)");
                }
            }

            if (canClick) {
                if (!_sounds.useUnityPointerEnterSound) {
                    unusedEventTypes.Add("Pointer Enter (uGUI)");
                }
                if (!_sounds.useUnityPointerExitSound) {
                    unusedEventTypes.Add("Pointer Exit (uGUI)");
                }
                if (!_sounds.useUnityPointerDownSound) {
                    unusedEventTypes.Add("Pointer Down (uGUI)");
                }
                if (!_sounds.useUnityPointerUpSound) {
                    unusedEventTypes.Add("Pointer Up (uGUI)");
                }
                if (!_sounds.useUnityDragSound) {
                    unusedEventTypes.Add("Drag (uGUI)");
                }
                if (!_sounds.useUnityDropSound) {
                    unusedEventTypes.Add("Drop (uGUI)");
                }
                if (!_sounds.useUnityScrollSound) {
                    unusedEventTypes.Add("Scroll (uGUI)");
                }
                if (!_sounds.useUnityUpdateSelectedSound) {
                    unusedEventTypes.Add("Update Selected (uGUI)");
                }
                if (!_sounds.useUnitySelectSound) {
                    unusedEventTypes.Add("Select (uGUI)");
                }
                if (!_sounds.useUnityDeselectSound) {
                    unusedEventTypes.Add("Deselect (uGUI)");
                }
                if (!_sounds.useUnityMoveSound) {
                    unusedEventTypes.Add("Move (uGUI)");
                }
                if (!_sounds.useUnityInitializePotentialDragSound) {
                    unusedEventTypes.Add("Initialize Potential Drag (uGUI)");
                }
                if (!_sounds.useUnityBeginDragSound) {
                    unusedEventTypes.Add("Begin Drag (uGUI)");
                }
                if (!_sounds.useUnityEndDragSound) {
                    unusedEventTypes.Add("End Drag (uGUI)");
                }
                if (!_sounds.useUnitySubmitSound) {
                    unusedEventTypes.Add("Submit (uGUI)");
                }
                if (!_sounds.useUnityCancelSound) {
                    unusedEventTypes.Add("Cancel (uGUI)");
                }
                if (!_sounds.useUnityToggleSound) {
                    unusedEventTypes.Add("Toggle (uGUI)");
                }
            }
        }
        #pragma warning restore 162
        // ReSharper restore HeuristicUnreachableCode

        if (!_sounds.useNguiOnClickSound && _sounds.showNGUI) {
            unusedEventTypes.Add("NGUI Mouse Click");
        }
        if (!_sounds.useNguiMouseDownSound && _sounds.showNGUI) {
            unusedEventTypes.Add("NGUI Mouse Down");
        }
        if (!_sounds.useNguiMouseUpSound && _sounds.showNGUI) {
            unusedEventTypes.Add("NGUI Mouse Up");
        }
        if (!_sounds.useNguiMouseEnterSound && _sounds.showNGUI) {
            unusedEventTypes.Add("NGUI Mouse Enter");
        }
        if (!_sounds.useNguiMouseExitSound && _sounds.showNGUI) {
            unusedEventTypes.Add("NGUI Mouse Exit");
        }
        if (!_sounds.useSpawnedSound && _sounds.showPoolManager) {
            unusedEventTypes.Add("Spawned");
        }
        if (!_sounds.useDespawnedSound && _sounds.showPoolManager) {
            unusedEventTypes.Add("Despawned");
        }

        if (_hasMechanim) {
            unusedEventTypes.Add("Mechanim State Entered");
        }

        unusedEventTypes.Add("Custom Event");

        var newDisable = EditorGUILayout.Toggle("Disable Sounds", _sounds.disableSounds);
        if (newDisable != _sounds.disableSounds) {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Disable Sounds");
            _sounds.disableSounds = newDisable;
        }

        if (!_sounds.disableSounds) {
            var newGiz = EditorGUILayout.Toggle("Show 3D Gizmo", _sounds.showGizmo);
            if (newGiz != _sounds.showGizmo) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Show 3D Gizmo");
                _sounds.showGizmo = newGiz;
            }

            var newSpawnMode = (MasterAudio.SoundSpawnLocationMode)EditorGUILayout.EnumPopup("Sound Spawn Mode", _sounds.soundSpawnMode);
            if (newSpawnMode != _sounds.soundSpawnMode) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Spawn Mode");
                _sounds.soundSpawnMode = newSpawnMode;
            }

            var newUI = (EventSounds.UnityUIVersion)EditorGUILayout.EnumPopup("Unity UI Version", _sounds.unityUIMode);
            if (newUI != _sounds.unityUIMode) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Unity UI Version");
                _sounds.unityUIMode = newUI;
            }

            var newNGUI = EditorGUILayout.Toggle("NGUI Events", _sounds.showNGUI);
            if (newNGUI != _sounds.showNGUI) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle NGUI Events");
                _sounds.showNGUI = newNGUI;
            }

            var newPM = EditorGUILayout.Toggle("Pooling Events", _sounds.showPoolManager);
            if (newPM != _sounds.showPoolManager) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Pooling Events");
                _sounds.showPoolManager = newPM;
            }

            var newLogMissing = EditorGUILayout.Toggle("Log Missing Events", _sounds.logMissingEvents);
            if (newLogMissing != _sounds.logMissingEvents) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Log Missing Events");
                _sounds.logMissingEvents = newLogMissing;
            }

            EditorGUILayout.BeginHorizontal();
            var newEventIndex = EditorGUILayout.Popup("Event To Activate", -1, unusedEventTypes.ToArray());
            DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/EventSounds.htm#SupportedEvents");

            EditorGUILayout.EndHorizontal();
            if (newEventIndex > -1) {
                var selectedEvent = unusedEventTypes[newEventIndex];
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "Active Event");

                switch (selectedEvent) {
                    case "Start":
                        _sounds.useStartSound = true;
                        AddEventIfZero(_sounds.startSound);
                        break;
                    case "Enable":
                        _sounds.useEnableSound = true;
                        AddEventIfZero(_sounds.enableSound);
                        break;
                    case "Disable":
                        _sounds.useDisableSound = true;
                        AddEventIfZero(_sounds.disableSound);
                        break;
                    case "Visible":
                        _sounds.useVisibleSound = true;
                        AddEventIfZero(_sounds.visibleSound);
                        break;
                    case "Invisible":
                        _sounds.useInvisibleSound = true;
                        AddEventIfZero(_sounds.invisibleSound);
                        break;
                    case "2D Collision Enter":
                        _sounds.useCollision2dSound = true;
                        AddEventIfZero(_sounds.collision2dSound);
                        break;
                    case "2D Collision Exit":
                        _sounds.useCollisionExit2dSound = true;
                        AddEventIfZero(_sounds.collisionExit2dSound);
                        break;
                    case "2D Trigger Enter":
                        _sounds.useTriggerEnter2dSound = true;
                        AddEventIfZero(_sounds.triggerEnter2dSound);
                        break;
                    case "2D Trigger Exit":
                        _sounds.useTriggerExit2dSound = true;
                        AddEventIfZero(_sounds.triggerExit2dSound);
                        break;
                    case "Collision Enter":
                        _sounds.useCollisionSound = true;
                        AddEventIfZero(_sounds.collisionSound);
                        break;
                    case "Collision Exit":
                        _sounds.useCollisionExitSound = true;
                        AddEventIfZero(_sounds.collisionExitSound);
                        break;
                    case "Trigger Enter":
                        _sounds.useTriggerEnterSound = true;
                        AddEventIfZero(_sounds.triggerSound);
                        break;
                    case "Trigger Exit":
                        _sounds.useTriggerExitSound = true;
                        AddEventIfZero(_sounds.triggerExitSound);
                        break;
                    case "Particle Collision":
                        _sounds.useParticleCollisionSound = true;
                        AddEventIfZero(_sounds.particleCollisionSound);
                        break;
                    case "Mouse Enter (Legacy)":
                        _sounds.useMouseEnterSound = true;
                        AddEventIfZero(_sounds.mouseEnterSound);
                        break;
                    case "Mouse Exit (Legacy)":
                        _sounds.useMouseExitSound = true;
                        AddEventIfZero(_sounds.mouseExitSound);
                        break;
                    case "Mouse Down (Legacy)":
                        _sounds.useMouseClickSound = true;
                        AddEventIfZero(_sounds.mouseClickSound);
                        break;
                    case "Mouse Drag (Legacy)":
                        _sounds.useMouseDragSound = true;
                        AddEventIfZero(_sounds.mouseDragSound);
                        break;
                    case "Mouse Up (Legacy)":
                        _sounds.useMouseUpSound = true;
                        AddEventIfZero(_sounds.mouseUpSound);
                        break;
                    case "Slider Changed (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnitySliderChanged);
                        break;
                    case "Button Click (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityButtonClicked);
                        break;
                    case "Pointer Down (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityPointerDown);
                        break;
                    case "Pointer Up (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityPointerUp);
                        break;
                    case "Drag (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityDrag);
                        break;
                    case "Drop (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityDrop);
                        break;
                    case "Pointer Enter (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityPointerEnter);
                        break;
                    case "Pointer Exit (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityPointerExit);
                        break;
                    case "Scroll (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityScroll);
                        break;
                    case "Update Selected (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityUpdateSelected);
                        break;
                    case "Select (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnitySelect);
                        break;
                    case "Deselect (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityDeselect);
                        break;
                    case "Move (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityMove);
                        break;
                    case "Initialize Potential Drag (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityInitializePotentialDrag);
                        break;
                    case "Begin Drag (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityBeginDrag);
                        break;
                    case "End Drag (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityEndDrag);
                        break;
                    case "Submit (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnitySubmit);
                        break;
                    case "Cancel (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityCancel);
                        break;
                    case "Toggle (uGUI)":
                        ActivateEvent(EventSounds.EventType.UnityToggle);
                        break;
                    case "NGUI Mouse Click":
                        _sounds.useNguiOnClickSound = true;
                        AddEventIfZero(_sounds.nguiOnClickSound);
                        break;
                    case "NGUI Mouse Down":
                        _sounds.useNguiMouseDownSound = true;
                        AddEventIfZero(_sounds.nguiMouseDownSound);
                        break;
                    case "NGUI Mouse Up":
                        _sounds.useNguiMouseUpSound = true;
                        AddEventIfZero(_sounds.nguiMouseUpSound);
                        break;
                    case "NGUI Mouse Enter":
                        _sounds.useNguiMouseEnterSound = true;
                        AddEventIfZero(_sounds.nguiMouseEnterSound);
                        break;
                    case "NGUI Mouse Exit":
                        _sounds.useNguiMouseExitSound = true;
                        AddEventIfZero(_sounds.nguiMouseExitSound);
                        break;
                    case "Spawned":
                        _sounds.useSpawnedSound = true;
                        AddEventIfZero(_sounds.spawnedSound);
                        break;
                    case "Despawned":
                        _sounds.useDespawnedSound = true;
                        AddEventIfZero(_sounds.despawnedSound);
                        break;
                    case "Mechanim State Entered":
                        CreateMechanimStateEntered(false);
                        break;
                    case "Custom Event":
                        CreateCustomEvent(false);
                        break;
                    default:
                        Debug.LogError("Add code for event type: " + selectedEvent);
                        break;
                }
            }
        }

        if (_sounds.userDefinedSounds.Count > 0) {
            EditorGUILayout.BeginHorizontal();
            GUI.contentColor = DTGUIHelper.BrightButtonColor;
            if (GUILayout.Button("Alpha Sort Custom Event Triggers", EditorStyles.toolbarButton, GUILayout.Width(200))) {
                SortCustomEventTriggers();
            }
            EditorGUILayout.EndHorizontal();
            GUI.contentColor = Color.white;
        }

        EditorGUILayout.Separator();
        var suffix = string.Empty;
        if (_sounds.disableSounds) {
            suffix = " (DISABLED)";
        } else if (unusedEventTypes.Count > 0) {
            suffix = " (" + unusedEventTypes.Count + " hidden)";
        }
        GUILayout.Label("Sound Triggers" + suffix, EditorStyles.boldLabel);

        // trigger sounds
        if (_sounds.useStartSound) {
            RenderEventWithHeader("Start" + DisabledText, "toggle Start Sound", _sounds.startSound, EventSounds.EventType.OnStart);
        }

        if (_sounds.useEnableSound) {
            RenderEventWithHeader("Enable" + DisabledText, "toggle Enable Sound", _sounds.enableSound, EventSounds.EventType.OnEnable);
        }

        if (_sounds.useDisableSound) {
            RenderEventWithHeader("Disable" + DisabledText, "toggle Disable Sound", _sounds.disableSound, EventSounds.EventType.OnDisable);
        }

        if (_sounds.useVisibleSound) {
            RenderEventWithHeader("Visible" + DisabledText, "toggle Visible Sound", _sounds.visibleSound, EventSounds.EventType.OnVisible);
        }

        if (_sounds.useInvisibleSound) {
            RenderEventWithHeader("Invisible" + DisabledText, "toggle Invisible Sound", _sounds.invisibleSound, EventSounds.EventType.OnInvisible);
        }

        #if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
        // these events don't exist
        #else
        if (_sounds.useCollision2dSound) {
            RenderEventWithHeader("2D Collision Enter" + DisabledText, "toggle 2D Collision Enter Sound", _sounds.collision2dSound, EventSounds.EventType.OnCollision2D);
        }

        if (_sounds.useCollisionExit2dSound) {
            RenderEventWithHeader("2D Collision Exit" + DisabledText, "toggle 2D Collision Exit Sound", _sounds.collisionExit2dSound, EventSounds.EventType.OnCollisionExit2D);
        }

        if (_sounds.useTriggerEnter2dSound) {
            RenderEventWithHeader("2D Trigger Enter" + DisabledText, "toggle 2D Trigger Enter Sound", _sounds.triggerEnter2dSound, EventSounds.EventType.OnTriggerEnter2D);
        }

        if (_sounds.useTriggerExit2dSound) {
            RenderEventWithHeader("2D Trigger Exit" + DisabledText, "toggle 2D Trigger Exit Sound", _sounds.triggerExit2dSound, EventSounds.EventType.OnTriggerExit2D);
        }
        #endif

        if (_sounds.useCollisionSound) {
            RenderEventWithHeader("Collision Enter" + DisabledText, "toggle Collision Enter Sound", _sounds.collisionSound, EventSounds.EventType.OnCollision);
        }

        if (_sounds.useCollisionExitSound) {
            RenderEventWithHeader("Collision Exit" + DisabledText, "toggle Collision Exit Sound", _sounds.collisionExitSound, EventSounds.EventType.OnCollisionExit);
        }

        if (_sounds.useTriggerEnterSound) {
            RenderEventWithHeader("Trigger Enter" + DisabledText, "toggle Trigger Enter Sound", _sounds.triggerSound, EventSounds.EventType.OnTriggerEnter);
        }

        if (_sounds.useTriggerExitSound) {
            RenderEventWithHeader("Trigger Exit" + DisabledText, "toggle Trigger Exit Sound", _sounds.triggerExitSound, EventSounds.EventType.OnTriggerExit);
        }

        if (_sounds.useParticleCollisionSound) {
            RenderEventWithHeader("Particle Collision" + DisabledText, "toggle Particle Collision Sound", _sounds.particleCollisionSound, EventSounds.EventType.OnParticleCollision);
        }

        if (_sounds.useMouseEnterSound) {
            RenderEventWithHeader("Mouse Enter (Legacy)" + DisabledText, "toggle Mouse Enter (Legacy) Sound", _sounds.mouseEnterSound, EventSounds.EventType.OnMouseEnter);
        }

        if (_sounds.useMouseExitSound) {
            RenderEventWithHeader("Mouse Exit (Legacy)" + DisabledText, "toggle Mouse Exit (Legacy) Sound", _sounds.mouseExitSound, EventSounds.EventType.OnMouseExit);
        }

        if (_sounds.useMouseClickSound) {
            RenderEventWithHeader("Mouse Down (Legacy)" + DisabledText, "toggle Mouse Down (Legacy) Sound", _sounds.mouseClickSound, EventSounds.EventType.OnMouseClick);
        }

        if (_sounds.useMouseDragSound) {
            RenderEventWithHeader("Mouse Drag (Legacy)" + DisabledText, "toggle Mouse Drag (Legacy) Sound", _sounds.mouseDragSound, EventSounds.EventType.OnMouseDrag);
        }

        if (_sounds.useMouseUpSound) {
            RenderEventWithHeader("Mouse Up (Legacy)" + DisabledText, "toggle Mouse Up (Legacy) Sound", _sounds.mouseUpSound, EventSounds.EventType.OnMouseUp);
        }

        #if UNITY_4_6 || UNITY_5
        if (showNewUIEvents) {
            if (hasSlider) {
                if (_sounds.useUnitySliderChangedSound) {
                    RenderEventWithHeader("Slider Changed (uGUI)" + DisabledText, "toggle Slider Changed (uGUI) Sound", _sounds.unitySliderChangedSound, EventSounds.EventType.UnitySliderChanged);
                }
            }

            if (hasButton) {
                if (_sounds.useUnityButtonClickedSound) {
                    RenderEventWithHeader("Button Click (uGUI)" + DisabledText, "toggle Button Click (uGUI) Sound", _sounds.unityButtonClickedSound, EventSounds.EventType.UnityButtonClicked);
                }
            }

            if (hasToggle) {
                if (_sounds.useUnityToggleSound) {
                    RenderEventWithHeader("Toggle (uGUI)" + DisabledText, "toggle Toggle (uGUI) Sound", _sounds.unityToggleSound, EventSounds.EventType.UnityToggle);
                }
            }

            if (canClick) {
                if (_sounds.useUnityPointerEnterSound) {
                    RenderEventWithHeader("Pointer Enter (uGUI)" + DisabledText, "toggle Pointer Enter (uGUI) Sound", _sounds.unityPointerEnterSound, EventSounds.EventType.UnityPointerEnter);
                }

                if (_sounds.useUnityPointerExitSound) {
                    RenderEventWithHeader("Pointer Exit (uGUI)" + DisabledText, "toggle Pointer Exit (uGUI) Sound", _sounds.unityPointerExitSound, EventSounds.EventType.UnityPointerExit);
                }

                if (_sounds.useUnityPointerDownSound) {
                    RenderEventWithHeader("Pointer Down (uGUI)" + DisabledText, "toggle Pointer Down (uGUI) Sound", _sounds.unityPointerDownSound, EventSounds.EventType.UnityPointerDown);
                }

                if (_sounds.useUnityPointerUpSound) {
                    RenderEventWithHeader("Pointer Up (uGUI)" + DisabledText, "toggle Pointer Up (uGUI) Sound", _sounds.unityPointerUpSound, EventSounds.EventType.UnityPointerUp);
                }

                if (_sounds.useUnityDragSound) {
                    RenderEventWithHeader("Drag (uGUI)" + DisabledText, "toggle Drag (uGUI) Sound", _sounds.unityDragSound, EventSounds.EventType.UnityDrag);
                }

                if (_sounds.useUnityDropSound) {
                    RenderEventWithHeader("Drop (uGUI)" + DisabledText, "toggle Drop (uGUI) Sound", _sounds.unityDropSound, EventSounds.EventType.UnityDrop);
                }

                if (_sounds.useUnityScrollSound) {
                    RenderEventWithHeader("Scroll (uGUI)" + DisabledText, "toggle Scroll (uGUI) Sound", _sounds.unityScrollSound, EventSounds.EventType.UnityScroll);
                }

                if (_sounds.useUnityUpdateSelectedSound) {
                    RenderEventWithHeader("Update Selected (uGUI)" + DisabledText, "toggle Update Selected (uGUI) Sound", _sounds.unityUpdateSelectedSound, EventSounds.EventType.UnityUpdateSelected);
                }

                if (_sounds.useUnitySelectSound) {
                    RenderEventWithHeader("Select (uGUI)" + DisabledText, "toggle Select (uGUI) Sound", _sounds.unitySelectSound, EventSounds.EventType.UnitySelect);
                }

                if (_sounds.useUnityDeselectSound) {
                    RenderEventWithHeader("Deselect (uGUI)" + DisabledText, "toggle Deselect (uGUI) Sound", _sounds.unityDeselectSound, EventSounds.EventType.UnityDeselect);
                }

                if (_sounds.useUnityMoveSound) {
                    RenderEventWithHeader("Move (uGUI)" + DisabledText, "toggle Move (uGUI) Sound", _sounds.unityMoveSound, EventSounds.EventType.UnityMove);
                }

                if (_sounds.useUnityInitializePotentialDragSound) {
                    RenderEventWithHeader("Initialize Potential Drag (uGUI)" + DisabledText, "toggle Initialize Potential Drag (uGUI) Sound", _sounds.unityInitializePotentialDragSound, EventSounds.EventType.UnityInitializePotentialDrag);
                }

                if (_sounds.useUnityBeginDragSound) {
                    RenderEventWithHeader("Begin Drag (uGUI)" + DisabledText, "toggle Begin Drag (uGUI) Sound", _sounds.unityBeginDragSound, EventSounds.EventType.UnityBeginDrag);
                }

                if (_sounds.useUnityEndDragSound) {
                    RenderEventWithHeader("End Drag (uGUI)" + DisabledText, "toggle End Drag (uGUI) Sound", _sounds.unityEndDragSound, EventSounds.EventType.UnityEndDrag);
                }

                if (_sounds.useUnitySubmitSound) {
                    RenderEventWithHeader("Submit (uGUI)" + DisabledText, "toggle Submit (uGUI) Sound", _sounds.unitySubmitSound, EventSounds.EventType.UnitySubmit);
                }

                if (_sounds.useUnityCancelSound) {
                    RenderEventWithHeader("Cancel (uGUI)" + DisabledText, "toggle Cancel (uGUI) Sound", _sounds.unityCancelSound, EventSounds.EventType.UnityCancel);
                }
            }
        }
        #endif

        if (_sounds.showNGUI) {
            if (_sounds.useNguiOnClickSound) {
                RenderEventWithHeader("NGUI Mouse Click" + DisabledText, "toggle NGUI Mouse Click Sound", _sounds.nguiOnClickSound, EventSounds.EventType.NGUIOnClick);
            }

            if (_sounds.useNguiMouseDownSound) {
                RenderEventWithHeader("NGUI Mouse Down" + DisabledText, "toggle NGUI Mouse Down Sound", _sounds.nguiMouseDownSound, EventSounds.EventType.NGUIMouseDown);
            }

            if (_sounds.useNguiMouseUpSound) {
                RenderEventWithHeader("NGUI Mouse Up" + DisabledText, "toggle NGUI Mouse Up Sound", _sounds.nguiMouseUpSound, EventSounds.EventType.NGUIMouseUp);
            }

            if (_sounds.useNguiMouseEnterSound) {
                RenderEventWithHeader("NGUI Mouse Enter" + DisabledText, "toggle NGUI Mouse Enter Sound", _sounds.nguiMouseEnterSound, EventSounds.EventType.NGUIMouseEnter);
            }

            if (_sounds.useNguiMouseExitSound) {
                RenderEventWithHeader("NGUI Mouse Exit" + DisabledText, "toggle NGUI Mouse Exit Sound", _sounds.nguiMouseExitSound, EventSounds.EventType.NGUIMouseExit);
            }
        }

        if (_sounds.showPoolManager) {
            if (_sounds.useSpawnedSound) {
                RenderEventWithHeader("Spawned (Pooling)" + DisabledText, "toggle Spawned (Pooling) Sound", _sounds.spawnedSound, EventSounds.EventType.OnSpawned);
            }

            if (_sounds.useDespawnedSound) {
                RenderEventWithHeader("Despawned (Pooling)" + DisabledText, "toggle Despawned (Pooling) Sound", _sounds.despawnedSound, EventSounds.EventType.OnDespawned);
            }
        }

        if (_sounds.mechanimStateChangedSounds.Count > 0) {
            EditorGUI.indentLevel = 0;

            // ReSharper disable once ForCanBeConvertedToForeach
            for (var i = 0; i < _sounds.mechanimStateChangedSounds.Count; i++) {
                var mechEvt = _sounds.mechanimStateChangedSounds[i];

                var mechName = "Mechanim State Entered";
                if (!string.IsNullOrEmpty(mechEvt.mechanimStateName)) {
                    mechName += ": " + mechEvt.mechanimStateName;
                }
                mechName += DisabledText;

                RenderEventWithHeader(mechName, "toggle " + mechName, mechEvt, EventSounds.EventType.MechanimStateChanged, i);
            }
        }

        if (_sounds.userDefinedSounds.Count > 0) {
            EditorGUI.indentLevel = 0;

            // ReSharper disable once ForCanBeConvertedToForeach
            for (var i = 0; i < _sounds.userDefinedSounds.Count; i++) {
                var customEventGrp = _sounds.userDefinedSounds[i];

                var custName = "Custom Event";
                if (!string.IsNullOrEmpty(customEventGrp.customEventName)) {
                    custName += ": " + customEventGrp.customEventName;
                }
                custName += DisabledText;

                RenderEventWithHeader(custName, "toggle " + custName, customEventGrp, EventSounds.EventType.UserDefinedEvent, i);
            }
        }

        if (GUI.changed || _isDirty || _changedList.Contains(true)) {
            EditorUtility.SetDirty(target);
        }

        //DrawDefaultInspector();
    }
Ejemplo n.º 9
0
    // ReSharper disable once FunctionComplexityOverflow
    private bool RenderAudioEvent(AudioEventGroup eventGrp, EventSounds.EventType eType)
    {
        DTGUIHelper.BeginGroupedControls();

        int? indexToRemove = null;
        int? indexToInsert = null;
        int? indexToShiftUp = null;
        int? indexToShiftDown = null;
        var hideActions = _sounds.disableSounds;

        var isSliderChangedEvent = (eType == EventSounds.EventType.UnitySliderChanged);

        if (_sounds.useMouseDragSound && eType == EventSounds.EventType.OnMouseUp) {
            var newStopDragSound = (EventSounds.PreviousSoundStopMode)EditorGUILayout.EnumPopup("Mouse Drag Sound End", eventGrp.mouseDragStopMode);
            if (newStopDragSound != eventGrp.mouseDragStopMode) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Mouse Drag Sound End");
                eventGrp.mouseDragStopMode = newStopDragSound;
            }

            if (eventGrp.mouseDragStopMode == EventSounds.PreviousSoundStopMode.FadeOut) {
                EditorGUI.indentLevel = 1;
                var newFade = EditorGUILayout.Slider("Mouse Drag Fade Time", eventGrp.mouseDragFadeOutTime, 0f, 1f);
                if (newFade != eventGrp.mouseDragFadeOutTime) {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Mouse Drag Fade Time");
                    eventGrp.mouseDragFadeOutTime = newFade;
                }
            }
        }

        EditorGUI.indentLevel = 0;
        var showLayerTagFilter = EventSounds.LayerTagFilterEvents.Contains(eType.ToString());

        if (showLayerTagFilter) {
            DTGUIHelper.StartGroupHeader();
            var newUseLayers = EditorGUILayout.BeginToggleGroup(" Layer filter", eventGrp.useLayerFilter);
            if (newUseLayers != eventGrp.useLayerFilter) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Layer filter");
                eventGrp.useLayerFilter = newUseLayers;
            }

            DTGUIHelper.EndGroupHeader();

            if (eventGrp.useLayerFilter) {
                for (var i = 0; i < eventGrp.matchingLayers.Count; i++) {
                    var newLayer = EditorGUILayout.LayerField("Layer Match " + (i + 1), eventGrp.matchingLayers[i]);
                    if (newLayer == eventGrp.matchingLayers[i]) {
                        continue;
                    }
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Layer filter");
                    eventGrp.matchingLayers[i] = newLayer;
                }
                EditorGUILayout.BeginHorizontal();

                GUI.contentColor = DTGUIHelper.BrightButtonColor;
                if (GUILayout.Button(new GUIContent("Add", "Click to add a layer match at the end"), EditorStyles.toolbarButton, GUILayout.Width(60))) {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "add Layer filter");
                    eventGrp.matchingLayers.Add(0);
                }
                if (eventGrp.matchingLayers.Count > 1) {
                    GUILayout.Space(10);
                    if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last layer match"), EditorStyles.toolbarButton, GUILayout.Width(60))) {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "remove Layer filter");
                        eventGrp.matchingLayers.RemoveAt(eventGrp.matchingLayers.Count - 1);
                    }
                }
                GUI.contentColor = Color.white;
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();
            DTGUIHelper.AddSpaceForNonU5(2);

            DTGUIHelper.StartGroupHeader();

            var newTagFilter = EditorGUILayout.BeginToggleGroup(" Tag filter", eventGrp.useTagFilter);
            if (newTagFilter != eventGrp.useTagFilter) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Tag filter");
                eventGrp.useTagFilter = newTagFilter;
            }

            DTGUIHelper.EndGroupHeader();

            if (eventGrp.useTagFilter) {
                for (var i = 0; i < eventGrp.matchingTags.Count; i++) {
                    var newTag = EditorGUILayout.TagField("Tag Match " + (i + 1), eventGrp.matchingTags[i]);
                    if (newTag == eventGrp.matchingTags[i]) {
                        continue;
                    }
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Tag filter");
                    eventGrp.matchingTags[i] = newTag;
                }
                EditorGUILayout.BeginHorizontal();
                GUI.contentColor = DTGUIHelper.BrightButtonColor;
                if (GUILayout.Button(new GUIContent("Add", "Click to add a tag match at the end"), EditorStyles.toolbarButton, GUILayout.Width(60))) {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "Add Tag filter");
                    eventGrp.matchingTags.Add("Untagged");
                }
                if (eventGrp.matchingTags.Count > 1) {
                    GUILayout.Space(10);
                    if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last tag match"), EditorStyles.toolbarButton, GUILayout.Width(60))) {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "remove Tag filter");
                        eventGrp.matchingTags.RemoveAt(eventGrp.matchingLayers.Count - 1);
                    }
                }
                GUI.contentColor = Color.white;
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();
        }

        if (eType == EventSounds.EventType.MechanimStateChanged) {
            if (!eventGrp.mechanimEventActive) {
                hideActions = true;
            }

            if (eventGrp.mechanimEventActive && !hideActions) {
                var newName = EditorGUILayout.TextField("State Name", eventGrp.mechanimStateName);
                if (newName != eventGrp.mechanimStateName) {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change State Name");
                    eventGrp.mechanimStateName = newName;
                }

                if (!_hasMechanim) {
                    DTGUIHelper.ShowRedError("This Game Object does not have an Animator component.");
                } else {
                    if (string.IsNullOrEmpty(eventGrp.mechanimStateName)) {
                        DTGUIHelper.ShowRedError("No State Name specified. This event will do nothing.");
                    }
                }
            }
        }

        if (eType == EventSounds.EventType.UserDefinedEvent) {
            if (!eventGrp.customSoundActive) {
                DTGUIHelper.EndGroupedControls();
                return true;
            }

            if (!hideActions) {
                if (_maInScene) {
                    var existingIndex = _customEventNames.IndexOf(eventGrp.customEventName);

                    int? customEventIndex = null;

                    EditorGUI.indentLevel = 0;

                    var noEvent = false;
                    var noMatch = false;

                    if (existingIndex >= 1) {
                        customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, _customEventNames.ToArray());
                        if (existingIndex == 1) {
                            noEvent = true;
                        }
                    } else if (existingIndex == -1 && eventGrp.customEventName == MasterAudio.NoGroupName) {
                        customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, _customEventNames.ToArray());
                    } else { // non-match
                        noMatch = true;
                        var newEventName = EditorGUILayout.TextField("Custom Event Name", eventGrp.customEventName);
                        if (newEventName != eventGrp.customEventName) {
                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Custom Event Name");
                            eventGrp.customEventName = newEventName;
                        }

                        var newIndex = EditorGUILayout.Popup("All Custom Events", -1, _customEventNames.ToArray());
                        if (newIndex >= 0) {
                            customEventIndex = newIndex;
                        }
                    }

                    if (noEvent) {
                        DTGUIHelper.ShowRedError("No Custom Event specified. This section will do nothing.");
                    } else if (noMatch) {
                        DTGUIHelper.ShowRedError("Custom Event found no match. Type in or choose one.");
                    }

                    if (customEventIndex.HasValue) {
                        if (existingIndex != customEventIndex.Value) {
                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Custom Event");
                        }
                        switch (customEventIndex.Value) {
                            case -1:
                                eventGrp.customEventName = MasterAudio.NoGroupName;
                                break;
                            default:
                                eventGrp.customEventName = _customEventNames[customEventIndex.Value];
                                break;
                        }
                    }
                } else {
                    var newCustomEvent = EditorGUILayout.TextField("Custom Event Name", eventGrp.customEventName);
                    if (newCustomEvent != eventGrp.customEventName) {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "Custom Event Name");
                        eventGrp.customEventName = newCustomEvent;
                    }
                }
            }
        }

        if (eventGrp.SoundEvents.Count == 0) {
            eventGrp.SoundEvents.Add(new AudioEvent());
        }

        if (!hideActions) {
            if (showLayerTagFilter) {
                DTGUIHelper.AddSpaceForNonU5(2);
            }
            DTGUIHelper.StartGroupHeader();
            EditorGUILayout.BeginHorizontal();

            var newRetrigger = (EventSounds.RetriggerLimMode)EditorGUILayout.EnumPopup("Retrigger Limit Mode", eventGrp.retriggerLimitMode);
            if (newRetrigger != eventGrp.retriggerLimitMode) {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Retrigger Limit Mode");
                eventGrp.retriggerLimitMode = newRetrigger;
            }

            DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/EventSounds.htm#Retrigger");

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();

            switch (eventGrp.retriggerLimitMode) {
                case EventSounds.RetriggerLimMode.FrameBased:
                    var newFrm = EditorGUILayout.IntSlider("Min Frames Between", eventGrp.limitPerXFrm, 0, 10000);
                    if (newFrm != eventGrp.limitPerXFrm) {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Min Frames Between");
                        eventGrp.limitPerXFrm = newFrm;
                    }
                    break;
                case EventSounds.RetriggerLimMode.TimeBased:
                    var newSec = EditorGUILayout.Slider("Min Seconds Between", eventGrp.limitPerXSec, 0f, 10000f);
                    if (newSec != eventGrp.limitPerXSec) {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Min Seconds Between");
                        eventGrp.limitPerXSec = newSec;
                    }
                    break;
            }
            EditorGUILayout.EndVertical();

            AudioEvent prevEvent = null;

            for (var j = 0; j < eventGrp.SoundEvents.Count; j++) {
                DTGUIHelper.AddSpaceForNonU5(2);
                var showVolumeSlider = true;
                var aEvent = eventGrp.SoundEvents[j];

                EditorGUI.indentLevel = 1;

                DTGUIHelper.StartGroupHeader();

                EditorGUILayout.BeginHorizontal();

                var newExpanded = DTGUIHelper.Foldout(aEvent.isExpanded, "Action #" + (j + 1));
                if (newExpanded != aEvent.isExpanded) {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle expand Action");
                    aEvent.isExpanded = newExpanded;
                }

                GUILayout.FlexibleSpace();

                var newActionName = GUILayout.TextField(aEvent.actionName, GUILayout.Width(150));
                if (newActionName != aEvent.actionName) {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "Rename action");
                    aEvent.actionName = newActionName;
                }

                var buttonPressed = DTGUIHelper.AddFoldOutListItemButtonItems(j, eventGrp.SoundEvents.Count, "Action", true, false, true);

                GUILayout.Space(4);
                DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/EventSounds.htm#Actions");

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
                GUI.backgroundColor = Color.white;

                if (prevEvent != null && prevEvent.IsFadeCommand) {
                    DTGUIHelper.ShowLargeBarAlert("This action will start immediately after the fade action above is *started*, not finished");
                }

                if (aEvent.isExpanded) {
                    EditorGUI.indentLevel = 0;

                    var newSoundType = (MasterAudio.EventSoundFunctionType)EditorGUILayout.EnumPopup("Action Type", aEvent.currentSoundFunctionType);
                    if (newSoundType != aEvent.currentSoundFunctionType) {
                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Action Type");
                        aEvent.currentSoundFunctionType = newSoundType;
                    }

                    switch (aEvent.currentSoundFunctionType) {
                        case MasterAudio.EventSoundFunctionType.PlaySound:
                            if (_maInScene) {
                                var existingIndex = _groupNames.IndexOf(aEvent.soundType);

                                int? groupIndex = null;

                                EditorGUI.indentLevel = 1;

                                var noGroup = false;
                                var noMatch = false;

                                if (existingIndex >= 1) {
                                    EditorGUILayout.BeginHorizontal();
                                    groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, _groupNames.ToArray());
                                    if (existingIndex == 1) {
                                        noGroup = true;
                                    }

                                    var button = DTGUIHelper.AddSettingsButton("Sound Group");
                                    switch (button) {
                                        case DTGUIHelper.DTFunctionButtons.Go:
                                            var grp = _groupNames[existingIndex];
                                            var trs = MasterAudio.FindGroupTransform(grp);
                                            if (trs != null) {
                                                Selection.activeObject = trs;
                                            }
                                            break;
                                    }

                                    EditorGUILayout.EndHorizontal();
                                } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NoGroupName) {
                                    groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, _groupNames.ToArray());
                                } else { // non-match
                                    noMatch = true;
                                    var newSound = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                    if (newSound != aEvent.soundType) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                                        aEvent.soundType = newSound;
                                    }

                                    var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, _groupNames.ToArray());
                                    if (newIndex >= 0) {
                                        groupIndex = newIndex;
                                    }
                                }

                                if (noGroup) {
                                    DTGUIHelper.ShowRedError("No Sound Group specified. Action will do nothing.");
                                } else if (noMatch) {
                                    DTGUIHelper.ShowRedError("Sound Group found no match. Type in or choose one.");
                                }

                                if (groupIndex.HasValue) {
                                    if (existingIndex != groupIndex.Value) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                                    }
                                    switch (groupIndex.Value) {
                                        case -1:
                                            aEvent.soundType = MasterAudio.NoGroupName;
                                            break;
                                        default:
                                            aEvent.soundType = _groupNames[groupIndex.Value];
                                            break;
                                    }
                                }
                            } else {
                                var newSType = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                if (newSType != aEvent.soundType) {
                                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                                    aEvent.soundType = newSType;
                                }
                            }

                            var newVarType = (EventSounds.VariationType)EditorGUILayout.EnumPopup("Variation Mode", aEvent.variationType);
                            if (newVarType != aEvent.variationType) {
                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Variation Mode");
                                aEvent.variationType = newVarType;
                            }

                            if (aEvent.variationType == EventSounds.VariationType.PlaySpecific) {
                                var newVarName = EditorGUILayout.TextField("Variation Name", aEvent.variationName);
                                if (newVarName != aEvent.variationName) {
                                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Variation Name");
                                    aEvent.variationName = newVarName;
                                }

                                if (string.IsNullOrEmpty(aEvent.variationName)) {
                                    DTGUIHelper.ShowRedError("Variation Name is empty. No sound will play.");
                                }
                            }

                            if (isSliderChangedEvent) {
                                var newSlider =
                                    (AudioEvent.TargetVolumeMode)
                                        EditorGUILayout.EnumPopup("Volume Mode", aEvent.targetVolMode);
                                if (newSlider != aEvent.targetVolMode) {
                                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                        "change Volume Mode");
                                    aEvent.targetVolMode = newSlider;
                                }

                                if (aEvent.targetVolMode == AudioEvent.TargetVolumeMode.UseSliderValue) {
                                    showVolumeSlider = false;
                                }
                            }

                            if (showVolumeSlider) {
                                var newVol = DTGUIHelper.DisplayVolumeField(aEvent.volume,
                                    DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true);
                                if (newVol != aEvent.volume) {
                                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Volume");
                                    aEvent.volume = newVol;
                                }
                            }

                            var newFixedPitch = EditorGUILayout.Toggle("Override pitch?", aEvent.useFixedPitch);
                            if (newFixedPitch != aEvent.useFixedPitch) {
                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Override pitch");
                                aEvent.useFixedPitch = newFixedPitch;
                            }
                            if (aEvent.useFixedPitch) {
                                var newPitch = DTGUIHelper.DisplayPitchField(aEvent.pitch);
                                if (newPitch != aEvent.pitch) {
                                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Pitch");
                                    aEvent.pitch = newPitch;
                                }
                            }

                            var newDelay = EditorGUILayout.Slider("Delay Sound (sec)", aEvent.delaySound, 0f, 10f);
                            if (newDelay != aEvent.delaySound) {
                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Delay Sound");
                                aEvent.delaySound = newDelay;
                            }
                            break;
                        case MasterAudio.EventSoundFunctionType.PlaylistControl:
                            EditorGUI.indentLevel = 1;
                            var newPlaylistCmd = (MasterAudio.PlaylistCommand)EditorGUILayout.EnumPopup("Playlist Command", aEvent.currentPlaylistCommand);
                            if (newPlaylistCmd != aEvent.currentPlaylistCommand) {
                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Playlist Command");
                                aEvent.currentPlaylistCommand = newPlaylistCmd;
                            }

                            if (aEvent.currentPlaylistCommand != MasterAudio.PlaylistCommand.None) {
                                // show Playlist Controller dropdown
                                if (EventSounds.PlaylistCommandsWithAll.Contains(aEvent.currentPlaylistCommand)) {
                                    var newAllControllers = EditorGUILayout.Toggle("All Playlist Controllers?", aEvent.allPlaylistControllersForGroupCmd);
                                    if (newAllControllers != aEvent.allPlaylistControllersForGroupCmd) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle All Playlist Controllers");
                                        aEvent.allPlaylistControllersForGroupCmd = newAllControllers;
                                    }
                                }

                                if (!aEvent.allPlaylistControllersForGroupCmd) {
                                    if (_playlistControllerNames.Count > 0) {
                                        var existingIndex = _playlistControllerNames.IndexOf(aEvent.playlistControllerName);

                                        int? playlistControllerIndex = null;

                                        var noPC = false;
                                        var noMatch = false;

                                        if (existingIndex >= 1) {
                                            playlistControllerIndex = EditorGUILayout.Popup("Playlist Controller", existingIndex, _playlistControllerNames.ToArray());
                                            if (existingIndex == 1) {
                                                noPC = true;
                                            }
                                        } else if (existingIndex == -1 && aEvent.playlistControllerName == MasterAudio.NoGroupName) {
                                            playlistControllerIndex = EditorGUILayout.Popup("Playlist Controller", existingIndex, _playlistControllerNames.ToArray());
                                        } else { // non-match
                                            noMatch = true;

                                            var newPlaylistController = EditorGUILayout.TextField("Playlist Controller", aEvent.playlistControllerName);
                                            if (newPlaylistController != aEvent.playlistControllerName) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Playlist Controller");
                                                aEvent.playlistControllerName = newPlaylistController;
                                            }
                                            var newIndex = EditorGUILayout.Popup("All Playlist Controllers", -1, _playlistControllerNames.ToArray());
                                            if (newIndex >= 0) {
                                                playlistControllerIndex = newIndex;
                                            }
                                        }

                                        if (noPC) {
                                            DTGUIHelper.ShowRedError("No Playlist Controller specified. Action will do nothing.");
                                        } else if (noMatch) {
                                            DTGUIHelper.ShowRedError("Playlist Controller found no match. Type in or choose one.");
                                        }

                                        if (playlistControllerIndex.HasValue) {
                                            if (existingIndex != playlistControllerIndex.Value) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Playlist Controller");
                                            }
                                            switch (playlistControllerIndex.Value) {
                                                case -1:
                                                    aEvent.playlistControllerName = MasterAudio.NoGroupName;
                                                    break;
                                                default:
                                                    aEvent.playlistControllerName = _playlistControllerNames[playlistControllerIndex.Value];
                                                    break;
                                            }
                                        }
                                    } else {
                                        var newPlaylistControllerName = EditorGUILayout.TextField("Playlist Controller", aEvent.playlistControllerName);
                                        if (newPlaylistControllerName != aEvent.playlistControllerName) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Playlist Controller");
                                            aEvent.playlistControllerName = newPlaylistControllerName;
                                        }
                                    }
                                }
                            }

                            switch (aEvent.currentPlaylistCommand) {
                                case MasterAudio.PlaylistCommand.None:
                                    DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                                    break;
                                case MasterAudio.PlaylistCommand.StopLoopingCurrentSong:
                                    break;
                                case MasterAudio.PlaylistCommand.ChangePlaylist:
                                case MasterAudio.PlaylistCommand.Start:
                                    // show playlist name dropdown
                                    if (_maInScene) {
                                        var existingIndex = _playlistNames.IndexOf(aEvent.playlistName);

                                        int? playlistIndex = null;

                                        var noPl = false;
                                        var noMatch = false;

                                        if (existingIndex >= 1) {
                                            playlistIndex = EditorGUILayout.Popup("Playlist Name", existingIndex, _playlistNames.ToArray());
                                            if (existingIndex == 1) {
                                                noPl = true;
                                            }
                                        } else if (existingIndex == -1 && aEvent.playlistName == MasterAudio.NoGroupName) {
                                            playlistIndex = EditorGUILayout.Popup("Playlist Name", existingIndex, _playlistNames.ToArray());
                                        } else { // non-match
                                            noMatch = true;

                                            var newPlaylist = EditorGUILayout.TextField("Playlist Name", aEvent.playlistName);
                                            if (newPlaylist != aEvent.playlistName) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Playlist Name");
                                                aEvent.playlistName = newPlaylist;
                                            }
                                            var newIndex = EditorGUILayout.Popup("All Playlists", -1, _playlistNames.ToArray());
                                            if (newIndex >= 0) {
                                                playlistIndex = newIndex;
                                            }
                                        }

                                        if (noPl) {
                                            DTGUIHelper.ShowRedError("No Playlist Name specified. Action will do nothing.");
                                        } else if (noMatch) {
                                            DTGUIHelper.ShowRedError("Playlist Name found no match. Type in or choose one.");
                                        }

                                        if (playlistIndex.HasValue) {
                                            if (existingIndex != playlistIndex.Value) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Playlist Name");
                                            }
                                            switch (playlistIndex.Value) {
                                                case -1:
                                                    aEvent.playlistName = MasterAudio.NoGroupName;
                                                    break;
                                                default:
                                                    aEvent.playlistName = _playlistNames[playlistIndex.Value];
                                                    break;
                                            }
                                        }
                                    } else {
                                        var newPlaylistName = EditorGUILayout.TextField("Playlist Name", aEvent.playlistName);
                                        if (newPlaylistName != aEvent.playlistName) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Playlist Name");
                                            aEvent.playlistName = newPlaylistName;
                                        }
                                    }

                                    if (aEvent.currentPlaylistCommand == MasterAudio.PlaylistCommand.ChangePlaylist) {
                                        var newStartPlaylist = EditorGUILayout.Toggle("Start Playlist?", aEvent.startPlaylist);
                                        if (newStartPlaylist != aEvent.startPlaylist) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Start Playlist");
                                            aEvent.startPlaylist = newStartPlaylist;
                                        }
                                    }
                                    break;
                                case MasterAudio.PlaylistCommand.FadeToVolume:
                                    if (isSliderChangedEvent) {
                                        var newSlider =
                                            (AudioEvent.TargetVolumeMode)
                                                EditorGUILayout.EnumPopup("Volume Mode", aEvent.targetVolMode);
                                        if (newSlider != aEvent.targetVolMode) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Volume Mode");
                                            aEvent.targetVolMode = newSlider;
                                        }

                                        if (aEvent.targetVolMode == AudioEvent.TargetVolumeMode.UseSliderValue) {
                                            showVolumeSlider = false;
                                        }
                                    }

                                    if (showVolumeSlider) {
                                        var newFadeVol = DTGUIHelper.DisplayVolumeField(aEvent.fadeVolume, DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true, "Target Volume");
                                        if (newFadeVol != aEvent.fadeVolume) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Target Volume");
                                            aEvent.fadeVolume = newFadeVol;
                                        }
                                    }

                                    var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                                    if (newFadeTime != aEvent.fadeTime) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Fade Time");
                                        aEvent.fadeTime = newFadeTime;
                                    }
                                    break;
                                case MasterAudio.PlaylistCommand.PlayClip:
                                    var newClip = EditorGUILayout.TextField("Clip Name", aEvent.clipName);
                                    if (newClip != aEvent.clipName) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Clip Name");
                                        aEvent.clipName = newClip;
                                    }
                                    if (string.IsNullOrEmpty(aEvent.clipName)) {
                                        DTGUIHelper.ShowRedError("Clip name is empty. Action will do nothing.");
                                    }
                                    break;
                            }
                            break;
                        case MasterAudio.EventSoundFunctionType.GroupControl:
                            EditorGUI.indentLevel = 1;

                            var newGroupCmd = (MasterAudio.SoundGroupCommand)EditorGUILayout.EnumPopup("Group Command", aEvent.currentSoundGroupCommand);
                            if (newGroupCmd != aEvent.currentSoundGroupCommand) {
                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Group Command");
                                aEvent.currentSoundGroupCommand = newGroupCmd;
                            }

                            if (!MasterAudio.GroupCommandsWithNoGroupSelector.Contains(aEvent.currentSoundGroupCommand)) {
                                if (!MasterAudio.GroupCommandsWithNoAllGroupSelector.Contains(aEvent.currentSoundGroupCommand)) {
                                    var newAllTypes = EditorGUILayout.Toggle("Do For Every Group?", aEvent.allSoundTypesForGroupCmd);
                                    if (newAllTypes != aEvent.allSoundTypesForGroupCmd) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Do For Every Group?");
                                        aEvent.allSoundTypesForGroupCmd = newAllTypes;
                                    }
                                }

                                if (!aEvent.allSoundTypesForGroupCmd) {
                                    if (_maInScene) {
                                        var existingIndex = _groupNames.IndexOf(aEvent.soundType);

                                        int? groupIndex = null;

                                        var noGroup = false;
                                        var noMatch = false;

                                        if (existingIndex >= 1) {
                                            groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, _groupNames.ToArray());
                                            if (existingIndex == 1) {
                                                noGroup = true;
                                            }

                                        } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NoGroupName) {
                                            groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, _groupNames.ToArray());
                                        } else { // non-match
                                            noMatch = true;

                                            var newSType = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                            if (newSType != aEvent.soundType) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                                                aEvent.soundType = newSType;
                                            }
                                            var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, _groupNames.ToArray());
                                            if (newIndex >= 0) {
                                                groupIndex = newIndex;
                                            }
                                        }

                                        if (noMatch) {
                                            DTGUIHelper.ShowRedError("Sound Group found no match. Type in or choose one.");
                                        } else if (noGroup) {
                                            DTGUIHelper.ShowRedError("No Sound Group specified. Action will do nothing.");
                                        }

                                        if (groupIndex.HasValue) {
                                            if (existingIndex != groupIndex.Value) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                                            }
                                            switch (groupIndex.Value) {
                                                case -1:
                                                    aEvent.soundType = MasterAudio.NoGroupName;
                                                    break;
                                                default:
                                                    aEvent.soundType = _groupNames[groupIndex.Value];
                                                    break;
                                            }
                                        }
                                    } else {
                                        var newSoundT = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                        if (newSoundT != aEvent.soundType) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                                            aEvent.soundType = newSoundT;
                                        }
                                    }
                                }
                            }

                            switch (aEvent.currentSoundGroupCommand) {
                                case MasterAudio.SoundGroupCommand.None:
                                    DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                                    break;
                                case MasterAudio.SoundGroupCommand.FadeToVolume:
                                    if (isSliderChangedEvent) {
                                        var newSlider =
                                            (AudioEvent.TargetVolumeMode)
                                                EditorGUILayout.EnumPopup("Volume Mode", aEvent.targetVolMode);
                                        if (newSlider != aEvent.targetVolMode) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Volume Mode");
                                            aEvent.targetVolMode = newSlider;
                                        }

                                        if (aEvent.targetVolMode == AudioEvent.TargetVolumeMode.UseSliderValue) {
                                            showVolumeSlider = false;
                                        }
                                    }

                                    if (showVolumeSlider) {
                                        var newFadeVol = DTGUIHelper.DisplayVolumeField(aEvent.fadeVolume,
                                            DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true, "Target Volume");
                                        if (newFadeVol != aEvent.fadeVolume) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Target Volume");
                                            aEvent.fadeVolume = newFadeVol;
                                        }
                                    }

                                    var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                                    if (newFadeTime != aEvent.fadeTime) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Fade Time");
                                        aEvent.fadeTime = newFadeTime;
                                    }
                                    break;
                                case MasterAudio.SoundGroupCommand.FadeOutAllOfSound:
                                    var newFadeT = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                                    if (newFadeT != aEvent.fadeTime) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Fade Time");
                                        aEvent.fadeTime = newFadeT;
                                    }
                                    break;
                                case MasterAudio.SoundGroupCommand.FadeOutSoundGroupOfTransform:
                                    var newFade = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                                    if (newFade != aEvent.fadeTime) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Fade Time");
                                        aEvent.fadeTime = newFade;
                                    }
                                    break;
                                case MasterAudio.SoundGroupCommand.Mute:
                                    break;
                                case MasterAudio.SoundGroupCommand.Pause:
                                    break;
                                case MasterAudio.SoundGroupCommand.Solo:
                                    break;
                                case MasterAudio.SoundGroupCommand.Unmute:
                                    break;
                                case MasterAudio.SoundGroupCommand.Unpause:
                                    break;
                                case MasterAudio.SoundGroupCommand.Unsolo:
                                    break;
                            }

                            break;
                        case MasterAudio.EventSoundFunctionType.BusControl:
                            EditorGUI.indentLevel = 1;
                            var newBusCmd = (MasterAudio.BusCommand)EditorGUILayout.EnumPopup("Bus Command", aEvent.currentBusCommand);
                            if (newBusCmd != aEvent.currentBusCommand) {
                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Bus Command");
                                aEvent.currentBusCommand = newBusCmd;
                            }

                            if (aEvent.currentBusCommand != MasterAudio.BusCommand.None) {
                                var newAllTypes = EditorGUILayout.Toggle("Do For Every Bus?", aEvent.allSoundTypesForBusCmd);
                                if (newAllTypes != aEvent.allSoundTypesForBusCmd) {
                                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Do For Every Bus?");
                                    aEvent.allSoundTypesForBusCmd = newAllTypes;
                                }

                                if (!aEvent.allSoundTypesForBusCmd) {
                                    if (_maInScene) {
                                        var existingIndex = _busNames.IndexOf(aEvent.busName);

                                        int? busIndex = null;

                                        var noBus = false;
                                        var noMatch = false;

                                        if (existingIndex >= 1) {
                                            busIndex = EditorGUILayout.Popup("Bus Name", existingIndex, _busNames.ToArray());
                                            if (existingIndex == 1) {
                                                noBus = true;
                                            }
                                        } else if (existingIndex == -1 && aEvent.busName == MasterAudio.NoGroupName) {
                                            busIndex = EditorGUILayout.Popup("Bus Name", existingIndex, _busNames.ToArray());
                                        } else { // non-match
                                            var newBusName = EditorGUILayout.TextField("Bus Name", aEvent.busName);
                                            if (newBusName != aEvent.busName) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Bus Name");
                                                aEvent.busName = newBusName;
                                            }

                                            var newIndex = EditorGUILayout.Popup("All Buses", -1, _busNames.ToArray());
                                            if (newIndex >= 0) {
                                                busIndex = newIndex;
                                            }
                                            noMatch = true;
                                        }

                                        if (noBus) {
                                            DTGUIHelper.ShowRedError("No Bus Name specified. Action will do nothing.");
                                        } else if (noMatch) {
                                            DTGUIHelper.ShowRedError("Bus Name found no match. Type in or choose one.");
                                        }

                                        if (busIndex.HasValue) {
                                            if (existingIndex != busIndex.Value) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Bus");
                                            }
                                            switch (busIndex.Value) {
                                                case -1:
                                                    aEvent.busName = MasterAudio.NoGroupName;
                                                    break;
                                                default:
                                                    aEvent.busName = _busNames[busIndex.Value];
                                                    break;
                                            }
                                        }
                                    } else {
                                        var newBusName = EditorGUILayout.TextField("Bus Name", aEvent.busName);
                                        if (newBusName != aEvent.busName) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Bus Name");
                                            aEvent.busName = newBusName;
                                        }
                                    }
                                }
                            }

                            switch (aEvent.currentBusCommand) {
                                case MasterAudio.BusCommand.None:
                                    DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                                    break;
                                case MasterAudio.BusCommand.ChangeBusPitch:
                                    var newPitch = DTGUIHelper.DisplayPitchField(aEvent.pitch);
                                    if (newPitch != aEvent.pitch) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Pitch");
                                        aEvent.pitch = newPitch;
                                    }
                                    break;
                                case MasterAudio.BusCommand.FadeToVolume:
                                    if (isSliderChangedEvent) {
                                        var newSlider =
                                            (AudioEvent.TargetVolumeMode)
                                                EditorGUILayout.EnumPopup("Volume Mode", aEvent.targetVolMode);
                                        if (newSlider != aEvent.targetVolMode) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Volume Mode");
                                            aEvent.targetVolMode = newSlider;
                                        }

                                        if (aEvent.targetVolMode == AudioEvent.TargetVolumeMode.UseSliderValue) {
                                            showVolumeSlider = false;
                                        }
                                    }

                                    if (showVolumeSlider) {
                                        var newFadeVol = DTGUIHelper.DisplayVolumeField(aEvent.fadeVolume,
                                            DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true, "Target Volume");
                                        if (newFadeVol != aEvent.fadeVolume) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Target Volume");
                                            aEvent.fadeVolume = newFadeVol;
                                        }
                                    }

                                    var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                                    if (newFadeTime != aEvent.fadeTime) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Fade Time");
                                        aEvent.fadeTime = newFadeTime;
                                    }
                                    break;
                                case MasterAudio.BusCommand.Pause:
                                    break;
                                case MasterAudio.BusCommand.Unpause:
                                    break;
                            }

                            break;
                        case MasterAudio.EventSoundFunctionType.CustomEventControl:
                            if (eType == EventSounds.EventType.UserDefinedEvent) {
                                DTGUIHelper.ShowRedError("Custom Event Receivers cannot fire events. Select another Action Type.");
                                break;
                            }

                            EditorGUI.indentLevel = 1;
                            var newEventCmd = (MasterAudio.CustomEventCommand)EditorGUILayout.EnumPopup("Custom Event Cmd", aEvent.currentCustomEventCommand);
                            if (newEventCmd != aEvent.currentCustomEventCommand) {
                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Custom Event Command");
                                aEvent.currentCustomEventCommand = newEventCmd;
                            }

                            switch (aEvent.currentCustomEventCommand) {
                                case MasterAudio.CustomEventCommand.None:
                                    DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                                    break;
                                case MasterAudio.CustomEventCommand.FireEvent:
                                    if (_maInScene) {
                                        var existingIndex = _customEventNames.IndexOf(aEvent.theCustomEventName);

                                        int? customEventIndex = null;

                                        EditorGUI.indentLevel = 1;

                                        var noEvent = false;
                                        var noMatch = false;

                                        if (existingIndex >= 1) {
                                            customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, _customEventNames.ToArray());
                                            if (existingIndex == 1) {
                                                noEvent = true;
                                            }
                                        } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NoGroupName) {
                                            customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, _customEventNames.ToArray());
                                        } else { // non-match
                                            noMatch = true;
                                            var newEventName = EditorGUILayout.TextField("Custom Event Name", aEvent.theCustomEventName);
                                            if (newEventName != aEvent.theCustomEventName) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Custom Event Name");
                                                aEvent.theCustomEventName = newEventName;
                                            }

                                            var newIndex = EditorGUILayout.Popup("All Custom Events", -1, _customEventNames.ToArray());
                                            if (newIndex >= 0) {
                                                customEventIndex = newIndex;
                                            }
                                        }

                                        if (noEvent) {
                                            DTGUIHelper.ShowRedError("No Custom Event specified. This section will do nothing.");
                                        } else if (noMatch) {
                                            DTGUIHelper.ShowRedError("Custom Event found no match. Type in or choose one.");
                                        }

                                        if (customEventIndex.HasValue) {
                                            if (existingIndex != customEventIndex.Value) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Custom Event");
                                            }
                                            switch (customEventIndex.Value) {
                                                case -1:
                                                    aEvent.theCustomEventName = MasterAudio.NoGroupName;
                                                    break;
                                                default:
                                                    aEvent.theCustomEventName = _customEventNames[customEventIndex.Value];
                                                    break;
                                            }
                                        }
                                    } else {
                                        var newCustomEvent = EditorGUILayout.TextField("Custom Event Name", aEvent.theCustomEventName);
                                        if (newCustomEvent != aEvent.theCustomEventName) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "Custom Event Name");
                                            aEvent.theCustomEventName = newCustomEvent;
                                        }
                                    }

                                    break;
                            }

                            break;
                        case MasterAudio.EventSoundFunctionType.GlobalControl:
                            EditorGUI.indentLevel = 1;
                            var newCmd = (MasterAudio.GlobalCommand)EditorGUILayout.EnumPopup("Global Cmd", aEvent.currentGlobalCommand);
                            if (newCmd != aEvent.currentGlobalCommand) {
                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Global Command");
                                aEvent.currentGlobalCommand = newCmd;
                            }

                            if (aEvent.currentGlobalCommand == MasterAudio.GlobalCommand.None) {
                                DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                            }

                            switch (aEvent.currentGlobalCommand) {
                                case MasterAudio.GlobalCommand.SetMasterMixerVolume:
                                    if (isSliderChangedEvent) {
                                        var newSlider =
                                            (AudioEvent.TargetVolumeMode)
                                                EditorGUILayout.EnumPopup("Volume Mode", aEvent.targetVolMode);
                                        if (newSlider != aEvent.targetVolMode) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Volume Mode");
                                            aEvent.targetVolMode = newSlider;
                                        }

                                        if (aEvent.targetVolMode == AudioEvent.TargetVolumeMode.UseSliderValue) {
                                            showVolumeSlider = false;
                                        }
                                    }

                                    if (showVolumeSlider) {
                                        var newFadeVol = DTGUIHelper.DisplayVolumeField(aEvent.volume,
                                            DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true, "Master Mixer Volume");
                                        if (newFadeVol != aEvent.volume) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Master Mixer Volume");
                                            aEvent.volume = newFadeVol;
                                        }
                                    }

                                    break;
                                case MasterAudio.GlobalCommand.SetMasterPlaylistVolume:
                                    if (isSliderChangedEvent) {
                                        var newSlider =
                                            (AudioEvent.TargetVolumeMode)
                                                EditorGUILayout.EnumPopup("Volume Mode", aEvent.targetVolMode);
                                        if (newSlider != aEvent.targetVolMode) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Volume Mode");
                                            aEvent.targetVolMode = newSlider;
                                        }

                                        if (aEvent.targetVolMode == AudioEvent.TargetVolumeMode.UseSliderValue) {
                                            showVolumeSlider = false;
                                        }
                                    }

                                    if (showVolumeSlider) {
                                        var newFadeVol = DTGUIHelper.DisplayVolumeField(aEvent.volume,
                                            DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true, "Master Playlist Volume");
                                        if (newFadeVol != aEvent.volume) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Master Playlist Volume");
                                            aEvent.volume = newFadeVol;
                                        }
                                    }

                                    break;
                            }
                            break;
        #if UNITY_5
                        case MasterAudio.EventSoundFunctionType.UnityMixerControl:
                            var newMix = (MasterAudio.UnityMixerCommand)EditorGUILayout.EnumPopup("Unity Mixer Cmd", aEvent.currentMixerCommand);
                            if (newMix != aEvent.currentMixerCommand) {
                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Unity Mixer Cmd");
                                aEvent.currentMixerCommand = newMix;
                            }

                            EditorGUI.indentLevel = 1;

                            switch (aEvent.currentMixerCommand) {
                                case MasterAudio.UnityMixerCommand.TransitionToSnapshot:
                                    var newTime = EditorGUILayout.Slider("Transition Time", aEvent.snapshotTransitionTime, 0, 100);
                                    if (newTime != aEvent.snapshotTransitionTime) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Transition Time");
                                        aEvent.snapshotTransitionTime = newTime;
                                    }

                                    var newSnap = (AudioMixerSnapshot)EditorGUILayout.ObjectField("Snapshot", aEvent.snapshotToTransitionTo, typeof(AudioMixerSnapshot), false);
                                    if (newSnap != aEvent.snapshotToTransitionTo) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Snapshot");
                                        aEvent.snapshotToTransitionTo = newSnap;
                                    }

                                    if (aEvent.snapshotToTransitionTo == null) {
                                        DTGUIHelper.ShowRedError("No snapshot selected. No transition will be made.");
                                    }

                                    break;
                                case MasterAudio.UnityMixerCommand.TransitionToSnapshotBlend:
                                    newTime = EditorGUILayout.Slider("Transition Time", aEvent.snapshotTransitionTime, 0, 100);
                                    if (newTime != aEvent.snapshotTransitionTime) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Transition Time");
                                        aEvent.snapshotTransitionTime = newTime;
                                    }

                                    if (aEvent.snapshotsToBlend.Count == 0) {
                                        DTGUIHelper.ShowRedError("You have no snapshots to blend. This action will do nothing.");
                                    } else {
                                        EditorGUILayout.Separator();
                                    }

                                    for (var i = 0; i < aEvent.snapshotsToBlend.Count; i++) {
                                        var aSnap = aEvent.snapshotsToBlend[i];
                                        newSnap = (AudioMixerSnapshot)EditorGUILayout.ObjectField("Snapshot #" + (i + 1), aSnap.snapshot, typeof(AudioMixerSnapshot), false);
                                        if (newSnap != aSnap.snapshot) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Snapshot");
                                            aSnap.snapshot = newSnap;
                                        }

                                        if (aSnap.snapshot == null) {
                                            DTGUIHelper.ShowRedError("No snapshot selected. This item will not be used for blending.");
                                            continue;
                                        }

                                        var newWeight = EditorGUILayout.Slider("Weight", aSnap.weight, 0f, 1f);
                                        if (newWeight != aSnap.weight) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Weight");
                                            aSnap.weight = newWeight;
                                        }
                                        EditorGUILayout.Separator();
                                    }

                                    EditorGUILayout.BeginHorizontal();
                                    GUILayout.Space(16);
                                    GUI.contentColor = DTGUIHelper.BrightButtonColor;
                                    if (GUILayout.Button(new GUIContent("Add Snapshot", "Click to add a Snapshot"), EditorStyles.toolbarButton, GUILayout.Width(85))) {
                                        aEvent.snapshotsToBlend.Add(new AudioEvent.MA_SnapshotInfo(null, 1f));
                                    }

                                    if (aEvent.snapshotsToBlend.Count > 0) {
                                        GUILayout.Space(6);
                                        GUI.contentColor = Color.red;
                                        if (DTGUIHelper.AddDeleteIcon("Snapshot", true)) {
                                            aEvent.snapshotsToBlend.RemoveAt(aEvent.snapshotsToBlend.Count - 1);
                                        }
                                    }

                                    EditorGUILayout.EndHorizontal();
                                    GUI.contentColor = Color.white;

                                    break;
                            }

                            break;
        #endif
                        case MasterAudio.EventSoundFunctionType.PersistentSettingsControl:
                            EditorGUI.indentLevel = 1;

                            var newPersistentCmd = (MasterAudio.PersistentSettingsCommand)EditorGUILayout.EnumPopup("Persistent Settings Command", aEvent.currentPersistentSettingsCommand);
                            if (newPersistentCmd != aEvent.currentPersistentSettingsCommand) {
                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Persistent Settings Command");
                                aEvent.currentPersistentSettingsCommand = newPersistentCmd;
                            }

                            switch (aEvent.currentPersistentSettingsCommand) {
                                case MasterAudio.PersistentSettingsCommand.None:
                                    DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                                    break;
                                case MasterAudio.PersistentSettingsCommand.SetBusVolume:

                                    var newAllTypes = EditorGUILayout.Toggle("Do For Every Bus?", aEvent.allSoundTypesForBusCmd);
                                    if (newAllTypes != aEvent.allSoundTypesForBusCmd) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Do For Every Bus?");
                                        aEvent.allSoundTypesForBusCmd = newAllTypes;
                                    }

                                    if (!aEvent.allSoundTypesForBusCmd) {
                                        if (_maInScene) {
                                            var existingIndex = _busNames.IndexOf(aEvent.busName);

                                            int? busIndex = null;

                                            var noBus = false;
                                            var noMatch = false;

                                            if (existingIndex >= 1) {
                                                busIndex = EditorGUILayout.Popup("Bus Name", existingIndex, _busNames.ToArray());
                                                if (existingIndex == 1) {
                                                    noBus = true;
                                                }
                                            } else if (existingIndex == -1 && aEvent.busName == MasterAudio.NoGroupName) {
                                                busIndex = EditorGUILayout.Popup("Bus Name", existingIndex, _busNames.ToArray());
                                            } else { // non-match
                                                var newBusName = EditorGUILayout.TextField("Bus Name", aEvent.busName);
                                                if (newBusName != aEvent.busName) {
                                                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Bus Name");
                                                    aEvent.busName = newBusName;
                                                }

                                                var newIndex = EditorGUILayout.Popup("All Buses", -1, _busNames.ToArray());
                                                if (newIndex >= 0) {
                                                    busIndex = newIndex;
                                                }
                                                noMatch = true;
                                            }

                                            if (noBus) {
                                                DTGUIHelper.ShowRedError("No Bus Name specified. Action will do nothing.");
                                            } else if (noMatch) {
                                                DTGUIHelper.ShowRedError("Bus Name found no match. Type in or choose one.");
                                            }

                                            if (busIndex.HasValue) {
                                                if (existingIndex != busIndex.Value) {
                                                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Bus");
                                                }
                                                switch (busIndex.Value) {
                                                    case -1:
                                                        aEvent.busName = MasterAudio.NoGroupName;
                                                        break;
                                                    default:
                                                        aEvent.busName = _busNames[busIndex.Value];
                                                        break;
                                                }
                                            }
                                        } else {
                                            var newBusName = EditorGUILayout.TextField("Bus Name", aEvent.busName);
                                            if (newBusName != aEvent.busName) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Bus Name");
                                                aEvent.busName = newBusName;
                                            }
                                        }
                                    }

                                    if (isSliderChangedEvent) {
                                        var newSlider =
                                            (AudioEvent.TargetVolumeMode)
                                                EditorGUILayout.EnumPopup("Volume Mode", aEvent.targetVolMode);
                                        if (newSlider != aEvent.targetVolMode) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Volume Mode");
                                            aEvent.targetVolMode = newSlider;
                                        }

                                        if (aEvent.targetVolMode == AudioEvent.TargetVolumeMode.UseSliderValue) {
                                            showVolumeSlider = false;
                                        }
                                    }

                                    if (showVolumeSlider) {
                                        var newVol = DTGUIHelper.DisplayVolumeField(aEvent.volume,
                                            DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true);
                                        if (newVol != aEvent.volume) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Volume");
                                            aEvent.volume = newVol;
                                        }
                                    }

                                    break;
                                case MasterAudio.PersistentSettingsCommand.SetGroupVolume:
                                    var newAllGrps = EditorGUILayout.Toggle("Do For Every Group?", aEvent.allSoundTypesForGroupCmd);
                                    if (newAllGrps != aEvent.allSoundTypesForGroupCmd) {
                                        AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "toggle Do For Every Group?");
                                        aEvent.allSoundTypesForGroupCmd = newAllGrps;
                                    }

                                    if (!aEvent.allSoundTypesForGroupCmd) {
                                        if (_maInScene) {
                                            var existingIndex = _groupNames.IndexOf(aEvent.soundType);

                                            int? groupIndex = null;

                                            var noGroup = false;
                                            var noMatch = false;

                                            if (existingIndex >= 1) {
                                                groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, _groupNames.ToArray());
                                                if (existingIndex == 1) {
                                                    noGroup = true;
                                                }

                                            } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NoGroupName) {
                                                groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, _groupNames.ToArray());
                                            } else { // non-match
                                                noMatch = true;

                                                var newSType = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                                if (newSType != aEvent.soundType) {
                                                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                                                    aEvent.soundType = newSType;
                                                }
                                                var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, _groupNames.ToArray());
                                                if (newIndex >= 0) {
                                                    groupIndex = newIndex;
                                                }
                                            }

                                            if (noMatch) {
                                                DTGUIHelper.ShowRedError("Sound Group found no match. Type in or choose one.");
                                            } else if (noGroup) {
                                                DTGUIHelper.ShowRedError("No Sound Group specified. Action will do nothing.");
                                            }

                                            if (groupIndex.HasValue) {
                                                if (existingIndex != groupIndex.Value) {
                                                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                                                }
                                                switch (groupIndex.Value) {
                                                    case -1:
                                                        aEvent.soundType = MasterAudio.NoGroupName;
                                                        break;
                                                    default:
                                                        aEvent.soundType = _groupNames[groupIndex.Value];
                                                        break;
                                                }
                                            }
                                        } else {
                                            var newSoundT = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                            if (newSoundT != aEvent.soundType) {
                                                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Sound Group");
                                                aEvent.soundType = newSoundT;
                                            }
                                        }
                                    }

                                    if (isSliderChangedEvent) {
                                        var newSlider =
                                            (AudioEvent.TargetVolumeMode)
                                                EditorGUILayout.EnumPopup("Volume Mode", aEvent.targetVolMode);
                                        if (newSlider != aEvent.targetVolMode) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Volume Mode");
                                            aEvent.targetVolMode = newSlider;
                                        }

                                        if (aEvent.targetVolMode == AudioEvent.TargetVolumeMode.UseSliderValue) {
                                            showVolumeSlider = false;
                                        }
                                    }

                                    if (showVolumeSlider) {
                                        var newVol = DTGUIHelper.DisplayVolumeField(aEvent.volume,
                                            DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true);
                                        if (newVol != aEvent.volume) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Volume");
                                            aEvent.volume = newVol;
                                        }
                                    }

                                    break;
                                case MasterAudio.PersistentSettingsCommand.SetMixerVolume:
                                    if (isSliderChangedEvent) {
                                        var newSlider =
                                            (AudioEvent.TargetVolumeMode)
                                                EditorGUILayout.EnumPopup("Volume Mode", aEvent.targetVolMode);
                                        if (newSlider != aEvent.targetVolMode) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Volume Mode");
                                            aEvent.targetVolMode = newSlider;
                                        }

                                        if (aEvent.targetVolMode == AudioEvent.TargetVolumeMode.UseSliderValue) {
                                            showVolumeSlider = false;
                                        }
                                    }

                                    if (showVolumeSlider) {
                                        var newVol = DTGUIHelper.DisplayVolumeField(aEvent.volume,
                                            DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true, "Mixer Volume");
                                        if (newVol != aEvent.volume) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Mixer Volume");
                                            aEvent.volume = newVol;
                                        }
                                    }

                                    break;
                                case MasterAudio.PersistentSettingsCommand.SetMusicVolume:
                                    if (isSliderChangedEvent) {
                                        var newSlider =
                                            (AudioEvent.TargetVolumeMode)
                                                EditorGUILayout.EnumPopup("Volume Mode", aEvent.targetVolMode);
                                        if (newSlider != aEvent.targetVolMode) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                                                "change Volume Mode");
                                            aEvent.targetVolMode = newSlider;
                                        }

                                        if (aEvent.targetVolMode == AudioEvent.TargetVolumeMode.UseSliderValue) {
                                            showVolumeSlider = false;
                                        }
                                    }

                                    if (showVolumeSlider) {
                                        var newVol = DTGUIHelper.DisplayVolumeField(aEvent.volume,
                                            DTGUIHelper.VolumeFieldType.None, MasterAudio.MixerWidthMode.Normal, 0f, true, "Music Volume");
                                        if (newVol != aEvent.volume) {
                                            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "change Music Volume");
                                            aEvent.volume = newVol;
                                        }
                                    }

                                    break;
                            }

                            break;
                    }

                    EditorGUI.indentLevel = 0;
                }

                switch (buttonPressed) {
                    case DTGUIHelper.DTFunctionButtons.Add:
                        indexToInsert = j + 1;
                        break;
                    case DTGUIHelper.DTFunctionButtons.Remove:
                        indexToRemove = j;
                        break;
                    case DTGUIHelper.DTFunctionButtons.ShiftUp:
                        indexToShiftUp = j;
                        break;
                    case DTGUIHelper.DTFunctionButtons.ShiftDown:
                        indexToShiftDown = j;
                        break;
                }

                prevEvent = aEvent;

                EditorGUILayout.EndVertical();
            }
        }

        AudioEvent item = null;

        if (indexToInsert.HasValue) {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "Add action");
            eventGrp.SoundEvents.Insert(indexToInsert.Value, new AudioEvent());
        } else if (indexToRemove.HasValue) {
            if (eventGrp.SoundEvents.Count <= 1) {
                DTGUIHelper.ShowAlert("You cannot delete the last Action. Delete this event trigger if you don't need it.");
            } else {
                AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "Delete action");
                eventGrp.SoundEvents.RemoveAt(indexToRemove.Value);
            }
        } else if (indexToShiftUp.HasValue) {
            item = eventGrp.SoundEvents[indexToShiftUp.Value];

            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "Shift up event action");

            eventGrp.SoundEvents.Insert(indexToShiftUp.Value - 1, item);
            eventGrp.SoundEvents.RemoveAt(indexToShiftUp.Value + 1);
        } else if (indexToShiftDown.HasValue) {
            var index = indexToShiftDown.Value + 1;
            item = eventGrp.SoundEvents[index];

            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, "Shift down event action");

            eventGrp.SoundEvents.Insert(index - 1, item);
            eventGrp.SoundEvents.RemoveAt(index + 1);
        }

        DTGUIHelper.EndGroupedControls();

        return _isDirty;
    }
Ejemplo n.º 10
0
        private void UpdateTimers()
        {
again:
            var arrayAppTimers = AppTimerManager.GetTimers();

            for (var i = 0; i < arrayAppTimers.Length; i++)
            {
                if (DateTime.Now <= arrayAppTimers[i].TriggerTime)
                {
                    continue;
                }

                if (AppVars.FastNeed)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(arrayAppTimers[i].Potion))
                {
                    FastStartSafe(arrayAppTimers[i].Potion, AppVars.Profile.UserNick, arrayAppTimers[i].DrinkCount);
                    if (arrayAppTimers[i].IsRecur)
                    {
                        var nextTimer = new AppTimer
                        {
                            TriggerTime =
                                arrayAppTimers[i].TriggerTime.AddMinutes(
                                    arrayAppTimers[i].EveryMinutes),
                            Description  = arrayAppTimers[i].Description,
                            Potion       = arrayAppTimers[i].Potion,
                            DrinkCount   = arrayAppTimers[i].DrinkCount,
                            IsRecur      = true,
                            EveryMinutes = arrayAppTimers[i].EveryMinutes
                        };
                        AppTimerManager.RemoveTimerAt(i);
                        AppTimerManager.AddAppTimer(nextTimer);
                    }
                    else
                    {
                        AppTimerManager.RemoveTimerAt(i);
                    }

                    EventSounds.PlayTimer();
                    ReloadMainFrame();
                    return;
                }

                var destination = arrayAppTimers[i].Destination;
                if (!string.IsNullOrEmpty(destination))
                {
                    AppTimerManager.RemoveTimerAt(i);
                    EventSounds.PlayTimer();
                    MoveTo(destination);
                    return;
                }

                var complect = arrayAppTimers[i].Complect;
                if (!string.IsNullOrEmpty(complect))
                {
                    AppVars.WearComplect = complect;
                    AppTimerManager.RemoveTimerAt(i);
                    EventSounds.PlayTimer();
                    ReloadMainFrame();
                    return;
                }

                AppTimerManager.RemoveTimerAt(i);
                EventSounds.PlayTimer();
                goto again;
            }

            if (dropdownTimers == null)
            {
                return;
            }
            var isNewList = true;

            if (arrayAppTimers.Length == (dropdownTimers.DropDownItems.Count - 1))
            {
                isNewList = false;
            }
            else
            {
                while (dropdownTimers.DropDownItems.Count > 1)
                {
                    dropdownTimers.DropDownItems.RemoveAt(1);
                }
            }

            if (arrayAppTimers.Length == 0)
            {
                dropdownTimers.Text = "Таймеры...";
            }
            else
            {
                dropdownTimers.Text = arrayAppTimers[0].ToString();
                for (var i = 0; i < arrayAppTimers.Length; i++)
                {
                    if (isNewList)
                    {
                        var item = new ToolStripMenuItem(arrayAppTimers[i].ToString())
                        {
                            Tag = i
                        };
                        if (arrayAppTimers[i].IsHerb)
                        {
                            item.Image        = Resources._15x12_herb;
                            item.ImageAlign   = ContentAlignment.MiddleCenter;
                            item.ImageScaling = ToolStripItemImageScaling.None;
                        }

                        item.Click += OnMenuitemWorkingTimerClick;
                        dropdownTimers.DropDownItems.Add(item);
                    }
                    else
                    {
                        dropdownTimers.DropDownItems[i + 1].Text = arrayAppTimers[i].ToString();
                        dropdownTimers.DropDownItems[i + 1].Tag  = i;
                        if (arrayAppTimers[i].IsHerb)
                        {
                            dropdownTimers.DropDownItems[i + 1].Image        = Resources._15x12_herb;
                            dropdownTimers.DropDownItems[i + 1].ImageAlign   = ContentAlignment.MiddleCenter;
                            dropdownTimers.DropDownItems[i + 1].ImageScaling = ToolStripItemImageScaling.None;
                        }
                        else
                        {
                            dropdownTimers.DropDownItems[i + 1].Image = null;
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initialize class
        /// </summary>
        /// <param name="gameObjectName"></param>
        public Vehicle(string gameObjectName)
        {
            // gameObject the object by name
            gameObject = GameObject.Find(gameObjectName);

            // Use Resources.FindObjectsOfTypeAll method, if the vehicle was not found.
            if (gameObject == null)
            {
                gameObject = Resources.FindObjectsOfTypeAll <GameObject>().FirstOrDefault(g => g.name == gameObjectName);
            }

            if (gameObject == null)
            {
                ModConsole.Error($"[MOP] Could not find {gameObjectName} vehicle.");
                return;
            }

            // Get the object position and rotation
            Position = gameObject.transform.localPosition;
            Rotation = gameObject.transform.localRotation;

            // Creates a new gameobject that is names after the original file + '_TEMP' (ex. "SATSUMA(557kg, 248)_TEMP")
            temporaryParent = new GameObject($"{gameObject.name}_TEMP").transform;

            preventToggleOnObjects = new List <PreventToggleOnObject>();

            // This should fix bug that leads to items inside of vehicles to fall through it.
            PlayMakerFSM lodFSM = gameObject.GetPlayMakerByName("LOD");

            if (lodFSM != null)
            {
                lodFSM.Fsm.RestartOnEnable = false;
                FsmState resetState = lodFSM.FindFsmState("Fix Collider");
                if (resetState != null)
                {
                    resetState.Actions = new FsmStateAction[] { new CustomStopAction() };
                    resetState.SaveActions();
                }

                lodFSM.FindFsmState("Load game").Actions = new FsmStateAction[] { new CustomNullState() };
            }

            if (gameObject.name == "BOAT")
            {
                return;
            }

            // Get the object's child which are responsible for audio
            foreach (Transform audioObject in FindAudioObjects())
            {
                preventToggleOnObjects.Add(new PreventToggleOnObject(audioObject));
            }

            // Fix for fuel level resetting after respawn
            Transform fuelTank = gameObject.transform.Find("FuelTank");

            if (fuelTank != null)
            {
                PlayMakerFSM fuelTankFSM = fuelTank.GetComponent <PlayMakerFSM>();
                if (fuelTankFSM)
                {
                    fuelTankFSM.Fsm.RestartOnEnable = false;
                }
            }

            // If the vehicle is Gifu, find knobs and add them to list of unloadable objects
            if (gameObject.name == "GIFU(750/450psi)")
            {
                Transform knobs = gameObject.transform.Find("Dashboard/Knobs");
                foreach (PlayMakerFSM knobsFSMs in knobs.GetComponentsInChildren <PlayMakerFSM>())
                {
                    knobsFSMs.Fsm.RestartOnEnable = false;
                }

                PlayMakerFSM          shitFsm          = gameObject.transform.Find("ShitTank").gameObject.GetComponent <PlayMakerFSM>();
                FsmState              loadGame         = shitFsm.FindFsmState("Load game");
                List <FsmStateAction> loadArrayActions = new List <FsmStateAction> {
                    new CustomNullState()
                };
                loadArrayActions.Add(new CustomNullState());
                loadGame.Actions = loadArrayActions.ToArray();
                loadGame.SaveActions();
            }

            // Fixed kickstand resetting to the default value.
            if (gameObject.name == "JONNEZ ES(Clone)")
            {
                PlayMakerFSM          kickstandFsm     = gameObject.transform.Find("Kickstand").gameObject.GetComponent <PlayMakerFSM>();
                FsmState              loadGame         = kickstandFsm.FindFsmState("Load game");
                List <FsmStateAction> loadArrayActions = new List <FsmStateAction> {
                    new CustomNullState()
                };
                loadArrayActions.Add(new CustomNullState());
                loadGame.Actions = loadArrayActions.ToArray();
                loadGame.SaveActions();

                // Disable on restart for wheels script.
                Transform wheelsParent = transform.Find("Wheels");
                foreach (Transform wheel in wheelsParent.GetComponentsInChildren <Transform>())
                {
                    if (!wheel.gameObject.name.StartsWith("Moped_wheel"))
                    {
                        continue;
                    }
                    wheel.gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false;
                }
            }

            carDynamics = gameObject.GetComponent <CarDynamics>();
            axles       = gameObject.GetComponent <Axles>();
            rb          = gameObject.GetComponent <Rigidbody>();

            // Hook HookFront and HookRear
            // Get hooks first
            Transform hookFront = transform.Find("HookFront");
            Transform hookRear  = transform.Find("HookRear");

            // If hooks exists, attach the RopeHookUp and RopeUnhook to appropriate states
            if (hookFront != null)
            {
                fsmHookFront = hookFront.GetComponent <PlayMakerFSM>();
            }

            if (hookRear != null)
            {
                fsmHookRear = hookRear.GetComponent <PlayMakerFSM>();
            }

            // If vehicle is flatbed, hook SwitchToggleMethod to Add scale script
            if (gameObject.name == "FLATBED")
            {
                PlayMakerFSM          logTriggerFsm    = transform.Find("Bed/LogTrigger").gameObject.GetComponent <PlayMakerFSM>();
                FsmState              loadGame         = logTriggerFsm.FindFsmState("Load game");
                List <FsmStateAction> loadArrayActions = new List <FsmStateAction> {
                    new CustomNullState()
                };
                loadGame.Actions = loadArrayActions.ToArray();
                loadGame.SaveActions();

                GameObject trailerLogUnderFloorCheck = new GameObject("MOP_TrailerLogUnderFloorFix");
                trailerLogUnderFloorCheck.transform.parent = gameObject.transform;
                trailerLogUnderFloorCheck.AddComponent <TrailerLogUnderFloor>();
            }

            // Set default toggling method - that is entire vehicle
            Toggle = ToggleActive;

            isHayosiko = gameObject.name == "HAYOSIKO(1500kg, 250)";
            isKekmet   = gameObject.name == "KEKMET(350-400psi)";

            // If the user selected to toggle vehicle's physics only, it overrided any previous set for Toggle method
            if (Rules.instance.SpecialRules.ToggleAllVehiclesPhysicsOnly)
            {
                Toggle = IgnoreToggle;
            }

            // Get all HingeJoints and add HingeManager to them
            // Ignore for Satsuma or cars that use ToggleUnityCar method (and force for Hayosiko - no matter what)
            if (SatsumaScript == null && Toggle != ToggleUnityCar || isHayosiko)
            {
                HingeJoint[] joints = gameObject.transform.GetComponentsInChildren <HingeJoint>();
                foreach (HingeJoint joint in joints)
                {
                    joint.gameObject.AddComponent <HingeManager>();
                }
            }

            // Get one of the wheels.
            wheel      = axles.allWheels[0];
            drivetrain = gameObject.GetComponent <Drivetrain>();

            // Ignore Rules.
            IgnoreRule vehicleRule = Rules.instance.IgnoreRules.Find(v => v.ObjectName == this.gameObject.name);

            if (vehicleRule != null)
            {
                Toggle = IgnoreToggle;

                if (vehicleRule.TotalIgnore)
                {
                    IsActive = false;
                }
            }

            // Prevent Toggle On Object Rule.
            IgnoreRuleAtPlace[] preventToggleOnObjectRule = Rules.instance.IgnoreRulesAtPlaces
                                                            .Where(v => v.Place == this.gameObject.name).ToArray();
            if (preventToggleOnObjectRule.Length > 0)
            {
                foreach (var p in preventToggleOnObjectRule)
                {
                    Transform t = transform.FindRecursive(p.ObjectName);
                    if (t == null)
                    {
                        ModConsole.Error($"[MOP] Couldn't find {p.ObjectName} in {p.Place}.");
                        continue;
                    }

                    preventToggleOnObjects.Add(new PreventToggleOnObject(t));
                }
            }

            eventSounds = gameObject.GetComponent <EventSounds>();

            // Odometers fix.
            switch (gameObject.name)
            {
            case "GIFU(750/450psi)":
                transform.Find("Dashboard/Odometer").gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false;
                break;

            case "HAYOSIKO(1500kg, 250)":
                transform.Find("Odometer").gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false;
                break;

            case "KEKMET(350-400psi)":
                transform.Find("Dashboard/HourMeter").gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false;
                break;

            case "SATSUMA(557kg, 248)":
                GameObject.Find("dashboard meters(Clone)").transform.Find("Gauges/Odometer").gameObject.GetComponent <PlayMakerFSM>().Fsm.RestartOnEnable = false;
                break;
            }
        }
Ejemplo n.º 12
0
    private bool RenderAudioEvent(AudioEventGroup eventGrp, EventSounds.EventType eType, int? itemIndex = null) {
        int? indexToRemove = null;
        int? indexToInsert = null;
        int? indexToShiftUp = null;
        int? indexToShiftDown = null;
        var hideActions = false;

        if (sounds.disableSounds) {
            hideActions = true;
        }

        if (sounds.useMouseDragSound && eType == EventSounds.EventType.OnMouseUp) {
            var newStopDragSound = (EventSounds.PreviousSoundStopMode)EditorGUILayout.EnumPopup("Mouse Drag Sound End", eventGrp.mouseDragStopMode);
            if (newStopDragSound != eventGrp.mouseDragStopMode) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Mouse Drag Sound End");
                eventGrp.mouseDragStopMode = newStopDragSound;
            }

            if (eventGrp.mouseDragStopMode == EventSounds.PreviousSoundStopMode.FadeOut) {
                EditorGUI.indentLevel = 1;
                var newFade = EditorGUILayout.Slider("Mouse Drag Fade Time", eventGrp.mouseDragFadeOutTime, 0f, 1f);
                if (newFade != eventGrp.mouseDragFadeOutTime) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Mouse Drag Fade Time");
                    eventGrp.mouseDragFadeOutTime = newFade;
                }
            }
        }

        EditorGUI.indentLevel = 0;
        bool showLayerTagFilter = EventSounds.layerTagFilterEvents.Contains(eType.ToString());

        if (showLayerTagFilter) {
            var newUseLayers = EditorGUILayout.BeginToggleGroup("Layer filters", eventGrp.useLayerFilter);
            if (newUseLayers != eventGrp.useLayerFilter) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Layer filters");
                eventGrp.useLayerFilter = newUseLayers;
            }
            if (eventGrp.useLayerFilter) {
                for (var i = 0; i < eventGrp.matchingLayers.Count; i++) {
                    var newLayer = EditorGUILayout.LayerField("Layer Match " + (i + 1), eventGrp.matchingLayers[i]);
                    if (newLayer != eventGrp.matchingLayers[i]) {
                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Layer filter");
                        eventGrp.matchingLayers[i] = newLayer;
                    }
                }
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(24);

                GUI.contentColor = Color.green;
                if (GUILayout.Button(new GUIContent("Add", "Click to add a layer match at the end"), EditorStyles.toolbarButton, GUILayout.Width(60))) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "add Layer filter");
                    eventGrp.matchingLayers.Add(0);
                }
                if (eventGrp.matchingLayers.Count > 1) {
                    GUILayout.Space(10);
                    if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last layer match"), EditorStyles.toolbarButton, GUILayout.Width(60))) {
                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "remove Layer filter");
                        eventGrp.matchingLayers.RemoveAt(eventGrp.matchingLayers.Count - 1);
                    }
                }
                GUI.contentColor = Color.white;
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();

            var newTagFilter = EditorGUILayout.BeginToggleGroup("Tag filter", eventGrp.useTagFilter);
            if (newTagFilter != eventGrp.useTagFilter) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Tag filter");
                eventGrp.useTagFilter = newTagFilter;
            }

            if (eventGrp.useTagFilter) {
                for (var i = 0; i < eventGrp.matchingTags.Count; i++) {
                    var newTag = EditorGUILayout.TagField("Tag Match " + (i + 1), eventGrp.matchingTags[i]);
                    if (newTag != eventGrp.matchingTags[i]) {
                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Tag filter");
                        eventGrp.matchingTags[i] = newTag;
                    }
                }
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(24);
                GUI.contentColor = Color.green;
                if (GUILayout.Button(new GUIContent("Add", "Click to add a tag match at the end"), EditorStyles.toolbarButton, GUILayout.Width(60))) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "Add Tag filter");
                    eventGrp.matchingTags.Add("Untagged");
                }
                if (eventGrp.matchingTags.Count > 1) {
                    GUILayout.Space(10);
                    if (GUILayout.Button(new GUIContent("Remove", "Click to remove the last tag match"), EditorStyles.toolbarButton, GUILayout.Width(60))) {
                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "remove Tag filter");
                        eventGrp.matchingTags.RemoveAt(eventGrp.matchingLayers.Count - 1);
                    }
                }
                GUI.contentColor = Color.white;
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndToggleGroup();
        }

        if (eType == EventSounds.EventType.MechanimStateChanged) {
            GUI.color = eventGrp.mechanimEventActive ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newUse = EditorGUILayout.Toggle("Mechanim State Entered " + DisabledText, eventGrp.mechanimEventActive);
            if (newUse != eventGrp.mechanimEventActive) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Mechanim State Entered active");
                eventGrp.mechanimEventActive = newUse;
            }

            if (!eventGrp.mechanimEventActive) {
                hideActions = true;
            }

            var buttonPressed = DTGUIHelper.AddCustomEventDeleteIcon(false);

            switch (buttonPressed) {
                case DTGUIHelper.DTFunctionButtons.Remove:
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "delete Custom Event Sound");
                    sounds.mechanimStateChangedSounds.RemoveAt(itemIndex.Value);
                    eventGrp.mechanimEventActive = false;
                    break;
            }

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

            if (eventGrp.mechanimEventActive && !hideActions) {
                var newName = EditorGUILayout.TextField("State Name", eventGrp.mechanimStateName);
                if (newName != eventGrp.mechanimStateName) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change State Name");
                    eventGrp.mechanimStateName = newName;
                }

                if (!hasMechanim) {
                    DTGUIHelper.ShowRedError("This Game Object does not have an Animator component. Add one or delete this.");
                } else {
                    if (string.IsNullOrEmpty(eventGrp.mechanimStateName)) {
                        DTGUIHelper.ShowRedError("No State Name specified. This event will do nothing.");
                    }
                }
            }
        }

        if (eType == EventSounds.EventType.UserDefinedEvent) {
            GUI.color = eventGrp.customSoundActive ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newUse = EditorGUILayout.Toggle("Custom Event " + DisabledText, eventGrp.customSoundActive);
            if (newUse != eventGrp.customSoundActive) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Custom Event active");
                eventGrp.customSoundActive = newUse;
            }

            var buttonPressed = DTGUIHelper.AddCustomEventDeleteIcon(false);

            switch (buttonPressed) {
                case DTGUIHelper.DTFunctionButtons.Remove:
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "delete Custom Event Sound");
                    sounds.userDefinedSounds.RemoveAt(itemIndex.Value);
                    eventGrp.customSoundActive = false;
                    break;
            }

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

            if (!eventGrp.customSoundActive) {
                return true;
            }

            if (!hideActions) {
                if (maInScene) {
                    var existingIndex = customEventNames.IndexOf(eventGrp.customEventName);

                    int? customEventIndex = null;

                    EditorGUI.indentLevel = 0;

                    var noEvent = false;
                    var noMatch = false;

                    if (existingIndex >= 1) {
                        customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, customEventNames.ToArray());
                        if (existingIndex == 1) {
                            noEvent = true;
                        }
                    } else if (existingIndex == -1 && eventGrp.customEventName == MasterAudio.NO_GROUP_NAME) {
                        customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, customEventNames.ToArray());
                    } else { // non-match
                        noMatch = true;
                        var newEventName = EditorGUILayout.TextField("Custom Event Name", eventGrp.customEventName);
                        if (newEventName != eventGrp.customEventName) {
                            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Custom Event Name");
                            eventGrp.customEventName = newEventName;
                        }

                        var newIndex = EditorGUILayout.Popup("All Custom Events", -1, customEventNames.ToArray());
                        if (newIndex >= 0) {
                            customEventIndex = newIndex;
                        }
                    }

                    if (noEvent) {
                        DTGUIHelper.ShowRedError("No Custom Event specified. This section will do nothing.");
                    } else if (noMatch) {
                        DTGUIHelper.ShowRedError("Custom Event found no match. Type in or choose one.");
                    }

                    if (customEventIndex.HasValue) {
                        if (existingIndex != customEventIndex.Value) {
                            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Custom Event");
                        }
                        if (customEventIndex.Value == -1) {
                            eventGrp.customEventName = MasterAudio.NO_GROUP_NAME;
                        } else {
                            eventGrp.customEventName = customEventNames[customEventIndex.Value];
                        }
                    }
                } else {
                    var newCustomEvent = EditorGUILayout.TextField("Custom Event Name", eventGrp.customEventName);
                    if (newCustomEvent != eventGrp.customEventName) {
                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "Custom Event Name");
                        eventGrp.customEventName = newCustomEvent;
                    }
                }
            }
        }

        if (eventGrp.SoundEvents.Count == 0) {
            eventGrp.SoundEvents.Add(new AudioEvent());
        }

        if (!hideActions) {
            for (var j = 0; j < eventGrp.SoundEvents.Count; j++) {
                AudioEvent aEvent = eventGrp.SoundEvents[j];

                var newRetrigger = (EventSounds.RetriggerLimMode)EditorGUILayout.EnumPopup("Retrigger Limit Mode", eventGrp.retriggerLimitMode);
                if (newRetrigger != eventGrp.retriggerLimitMode) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Retrigger Limit Mode");
                    eventGrp.retriggerLimitMode = newRetrigger;
                }

                EditorGUI.indentLevel = 1;
                switch (eventGrp.retriggerLimitMode) {
                    case EventSounds.RetriggerLimMode.FrameBased:
                        var newFrm = EditorGUILayout.IntSlider("Min Frames Between", eventGrp.limitPerXFrm, 0, 10000);
                        if (newFrm != eventGrp.limitPerXFrm) {
                            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Min Frames Between");
                            eventGrp.limitPerXFrm = newFrm;
                        }
                        break;
                    case EventSounds.RetriggerLimMode.TimeBased:
                        var newSec = EditorGUILayout.Slider("Min Seconds Between", eventGrp.limitPerXSec, 0f, 10000f);
                        if (newSec != eventGrp.limitPerXSec) {
                            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Min Seconds Between");
                            eventGrp.limitPerXSec = newSec;
                        }
                        break;
                }

                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newExpanded = DTGUIHelper.Foldout(aEvent.isExpanded, "Action #" + (j + 1));
                if (newExpanded != aEvent.isExpanded) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle expand Action");
                    aEvent.isExpanded = newExpanded;
                }

                var newActionName = GUILayout.TextField(aEvent.actionName, GUILayout.Width(200));
                if (newActionName != aEvent.actionName) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "Rename action");
                    aEvent.actionName = newActionName;
                }

                var buttonPressed = DTGUIHelper.AddFoldOutListItemButtons(j, eventGrp.SoundEvents.Count, "Action", true, true, false);
                EditorGUILayout.EndHorizontal();

                if (aEvent.isExpanded) {
                    EditorGUI.indentLevel = 0;

                    if (eType == EventSounds.EventType.OnEnable) {
                        DTGUIHelper.ShowColorWarning("*If this prefab is in the scene at startup, use Start event instead.");
                    }

                    var newSoundType = (MasterAudio.EventSoundFunctionType)EditorGUILayout.EnumPopup("Action Type", aEvent.currentSoundFunctionType);
                    if (newSoundType != aEvent.currentSoundFunctionType) {
                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Action Type");
                        aEvent.currentSoundFunctionType = newSoundType;
                    }

                    switch (aEvent.currentSoundFunctionType) {
                        case MasterAudio.EventSoundFunctionType.PlaySound:
                            if (maInScene) {
                                var existingIndex = groupNames.IndexOf(aEvent.soundType);

                                int? groupIndex = null;

                                EditorGUI.indentLevel = 1;

                                var noGroup = false;
                                var noMatch = false;

                                if (existingIndex >= 1) {
                                    groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray());
                                    if (existingIndex == 1) {
                                        noGroup = true;
                                    }
                                } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NO_GROUP_NAME) {
                                    groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray());
                                } else { // non-match
                                    noMatch = true;
                                    var newSound = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                    if (newSound != aEvent.soundType) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Sound Group");
                                        aEvent.soundType = newSound;
                                    }

                                    var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, groupNames.ToArray());
                                    if (newIndex >= 0) {
                                        groupIndex = newIndex;
                                    }
                                }

                                if (noGroup) {
                                    DTGUIHelper.ShowRedError("No Sound Group specified. Action will do nothing.");
                                } else if (noMatch) {
                                    DTGUIHelper.ShowRedError("Sound Group found no match. Type in or choose one.");
                                }

                                if (groupIndex.HasValue) {
                                    if (existingIndex != groupIndex.Value) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Sound Group");
                                    }
                                    if (groupIndex.Value == -1) {
                                        aEvent.soundType = MasterAudio.NO_GROUP_NAME;
                                    } else {
                                        aEvent.soundType = groupNames[groupIndex.Value];
                                    }
                                }
                            } else {
                                var newSType = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                if (newSType != aEvent.soundType) {
                                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Sound Group");
                                    aEvent.soundType = newSType;
                                }
                            }

                            var newVarType = (EventSounds.VariationType)EditorGUILayout.EnumPopup("Variation Mode", aEvent.variationType);
                            if (newVarType != aEvent.variationType) {
                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Variation Mode");
                                aEvent.variationType = newVarType;
                            }

                            if (aEvent.variationType == EventSounds.VariationType.PlaySpecific) {
                                var newVarName = EditorGUILayout.TextField("Variation Name", aEvent.variationName);
                                if (newVarName != aEvent.variationName) {
                                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Variation Name");
                                    aEvent.variationName = newVarName;
                                }

                                if (string.IsNullOrEmpty(aEvent.variationName)) {
                                    DTGUIHelper.ShowRedError("Variation Name is empty. No sound will play.");
                                }
                            }

                            var newVol = EditorGUILayout.Slider("Volume", aEvent.volume, 0f, 1f);
                            if (newVol != aEvent.volume) {
                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Volume");
                                aEvent.volume = newVol;
                            }

                            var newFixedPitch = EditorGUILayout.Toggle("Override pitch?", aEvent.useFixedPitch);
                            if (newFixedPitch != aEvent.useFixedPitch) {
                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Override pitch");
                                aEvent.useFixedPitch = newFixedPitch;
                            }
                            if (aEvent.useFixedPitch) {
                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Pitch");
                                aEvent.pitch = EditorGUILayout.Slider("Pitch", aEvent.pitch, -3f, 3f);
                            }

                            var newDelay = EditorGUILayout.Slider("Delay Sound (sec)", aEvent.delaySound, 0f, 10f);
                            if (newDelay != aEvent.delaySound) {
                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Delay Sound");
                                aEvent.delaySound = newDelay;
                            }
                            break;
                        case MasterAudio.EventSoundFunctionType.PlaylistControl:
                            EditorGUI.indentLevel = 1;
                            var newPlaylistCmd = (MasterAudio.PlaylistCommand)EditorGUILayout.EnumPopup("Playlist Command", aEvent.currentPlaylistCommand);
                            if (newPlaylistCmd != aEvent.currentPlaylistCommand) {
                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Playlist Command");
                                aEvent.currentPlaylistCommand = newPlaylistCmd;
                            }

                            if (aEvent.currentPlaylistCommand != MasterAudio.PlaylistCommand.None) {
                                // show Playlist Controller dropdown
                                if (EventSounds.playlistCommandsWithAll.Contains(aEvent.currentPlaylistCommand)) {
                                    var newAllControllers = EditorGUILayout.Toggle("All Playlist Controllers?", aEvent.allPlaylistControllersForGroupCmd);
                                    if (newAllControllers != aEvent.allPlaylistControllersForGroupCmd) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle All Playlist Controllers");
                                        aEvent.allPlaylistControllersForGroupCmd = newAllControllers;
                                    }
                                }

                                if (!aEvent.allPlaylistControllersForGroupCmd) {
                                    if (playlistControllerNames.Count > 0) {
                                        var existingIndex = playlistControllerNames.IndexOf(aEvent.playlistControllerName);

                                        int? playlistControllerIndex = null;

                                        var noPC = false;
                                        var noMatch = false;

                                        if (existingIndex >= 1) {
                                            playlistControllerIndex = EditorGUILayout.Popup("Playlist Controller", existingIndex, playlistControllerNames.ToArray());
                                            if (existingIndex == 1) {
                                                noPC = true;
                                            }
                                        } else if (existingIndex == -1 && aEvent.playlistControllerName == MasterAudio.NO_GROUP_NAME) {
                                            playlistControllerIndex = EditorGUILayout.Popup("Playlist Controller", existingIndex, playlistControllerNames.ToArray());
                                        } else { // non-match
                                            noMatch = true;

                                            var newPlaylistController = EditorGUILayout.TextField("Playlist Controller", aEvent.playlistControllerName);
                                            if (newPlaylistController != aEvent.playlistControllerName) {
                                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Playlist Controller");
                                                aEvent.playlistControllerName = newPlaylistController;
                                            }
                                            var newIndex = EditorGUILayout.Popup("All Playlist Controllers", -1, playlistControllerNames.ToArray());
                                            if (newIndex >= 0) {
                                                playlistControllerIndex = newIndex;
                                            }
                                        }

                                        if (noPC) {
                                            DTGUIHelper.ShowRedError("No Playlist Controller specified. Action will do nothing.");
                                        } else if (noMatch) {
                                            DTGUIHelper.ShowRedError("Playlist Controller found no match. Type in or choose one.");
                                        }

                                        if (playlistControllerIndex.HasValue) {
                                            if (existingIndex != playlistControllerIndex.Value) {
                                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Playlist Controller");
                                            }
                                            if (playlistControllerIndex.Value == -1) {
                                                aEvent.playlistControllerName = MasterAudio.NO_GROUP_NAME;
                                            } else {
                                                aEvent.playlistControllerName = playlistControllerNames[playlistControllerIndex.Value];
                                            }
                                        }
                                    } else {
                                        var newPlaylistControllerName = EditorGUILayout.TextField("Playlist Controller", aEvent.playlistControllerName);
                                        if (newPlaylistControllerName != aEvent.playlistControllerName) {
                                            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Playlist Controller");
                                            aEvent.playlistControllerName = newPlaylistControllerName;
                                        }
                                    }
                                }
                            }

                            switch (aEvent.currentPlaylistCommand) {
                                case MasterAudio.PlaylistCommand.None:
                                    DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                                    break;
                                case MasterAudio.PlaylistCommand.ChangePlaylist:
                                    // show playlist name dropdown
                                    if (maInScene) {
                                        var existingIndex = playlistNames.IndexOf(aEvent.playlistName);

                                        int? playlistIndex = null;

                                        var noPl = false;
                                        var noMatch = false;

                                        if (existingIndex >= 1) {
                                            playlistIndex = EditorGUILayout.Popup("Playlist Name", existingIndex, playlistNames.ToArray());
                                            if (existingIndex == 1) {
                                                noPl = true;
                                            }
                                        } else if (existingIndex == -1 && aEvent.playlistName == MasterAudio.NO_GROUP_NAME) {
                                            playlistIndex = EditorGUILayout.Popup("Playlist Name", existingIndex, playlistNames.ToArray());
                                        } else { // non-match
                                            noMatch = true;

                                            var newPlaylist = EditorGUILayout.TextField("Playlist Name", aEvent.playlistName);
                                            if (newPlaylist != aEvent.playlistName) {
                                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Playlist Name");
                                                aEvent.playlistName = newPlaylist;
                                            }
                                            var newIndex = EditorGUILayout.Popup("All Playlists", -1, playlistNames.ToArray());
                                            if (newIndex >= 0) {
                                                playlistIndex = newIndex;
                                            }
                                        }

                                        if (noPl) {
                                            DTGUIHelper.ShowRedError("No Playlist Name specified. Action will do nothing.");
                                        } else if (noMatch) {
                                            DTGUIHelper.ShowRedError("Playlist Name found no match. Type in or choose one.");
                                        }

                                        if (playlistIndex.HasValue) {
                                            if (existingIndex != playlistIndex.Value) {
                                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Playlist Name");
                                            }
                                            if (playlistIndex.Value == -1) {
                                                aEvent.playlistName = MasterAudio.NO_GROUP_NAME;
                                            } else {
                                                aEvent.playlistName = playlistNames[playlistIndex.Value];
                                            }
                                        }
                                    } else {
                                        var newPlaylistName = EditorGUILayout.TextField("Playlist Name", aEvent.playlistName);
                                        if (newPlaylistName != aEvent.playlistName) {
                                            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Playlist Name");
                                            aEvent.playlistName = newPlaylistName;
                                        }
                                    }

                                    var newStartPlaylist = EditorGUILayout.Toggle("Start Playlist?", aEvent.startPlaylist);
                                    if (newStartPlaylist != aEvent.startPlaylist) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Start Playlist");
                                        aEvent.startPlaylist = newStartPlaylist;
                                    }
                                    break;
                                case MasterAudio.PlaylistCommand.FadeToVolume:
                                    var newFadeVol = EditorGUILayout.Slider("Target Volume", aEvent.fadeVolume, 0f, 1f);
                                    if (newFadeVol != aEvent.fadeVolume) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Target Volume");
                                        aEvent.fadeVolume = newFadeVol;
                                    }

                                    var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                                    if (newFadeTime != aEvent.fadeTime) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Fade Time");
                                        aEvent.fadeTime = newFadeTime;
                                    }
                                    break;
                                case MasterAudio.PlaylistCommand.PlayClip:
                                    var newClip = EditorGUILayout.TextField("Clip Name", aEvent.clipName);
                                    if (newClip != aEvent.clipName) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Clip Name");
                                        aEvent.clipName = newClip;
                                    }
                                    if (string.IsNullOrEmpty(aEvent.clipName)) {
                                        DTGUIHelper.ShowRedError("Clip name is empty. Action will do nothing.");
                                    }
                                    break;
                            }
                            break;
                        case MasterAudio.EventSoundFunctionType.GroupControl:
                            EditorGUI.indentLevel = 1;

                            var newGroupCmd = (MasterAudio.SoundGroupCommand)EditorGUILayout.EnumPopup("Group Command", aEvent.currentSoundGroupCommand);
                            if (newGroupCmd != aEvent.currentSoundGroupCommand) {
                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Group Command");
                                aEvent.currentSoundGroupCommand = newGroupCmd;
                            }

                            if (!MasterAudio.GroupCommandsWithNoGroupSelector.Contains(aEvent.currentSoundGroupCommand)) {
                                if (!MasterAudio.GroupCommandsWithNoAllGroupSelector.Contains(aEvent.currentSoundGroupCommand)) {
                                    var newAllTypes = EditorGUILayout.Toggle("Do For Every Group?", aEvent.allSoundTypesForGroupCmd);
                                    if (newAllTypes != aEvent.allSoundTypesForGroupCmd) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Do For Every Group?");
                                        aEvent.allSoundTypesForGroupCmd = newAllTypes;
                                    }
                                }

                                if (!aEvent.allSoundTypesForGroupCmd) {
                                    if (maInScene) {
                                        var existingIndex = groupNames.IndexOf(aEvent.soundType);

                                        int? groupIndex = null;

                                        var noGroup = false;
                                        var noMatch = false;

                                        if (existingIndex >= 1) {
                                            groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray());
                                            if (existingIndex == 1) {
                                                noGroup = true;
                                            }

                                        } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NO_GROUP_NAME) {
                                            groupIndex = EditorGUILayout.Popup("Sound Group", existingIndex, groupNames.ToArray());
                                        } else { // non-match
                                            noMatch = true;

                                            var newSType = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                            if (newSType != aEvent.soundType) {
                                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Sound Group");
                                                aEvent.soundType = newSType;
                                            }
                                            var newIndex = EditorGUILayout.Popup("All Sound Groups", -1, groupNames.ToArray());
                                            if (newIndex >= 0) {
                                                groupIndex = newIndex;
                                            }
                                        }

                                        if (noMatch) {
                                            DTGUIHelper.ShowRedError("Sound Group found no match. Type in or choose one.");
                                        } else if (noGroup) {
                                            DTGUIHelper.ShowRedError("No Sound Group specified. Action will do nothing.");
                                        }

                                        if (groupIndex.HasValue) {
                                            if (existingIndex != groupIndex.Value) {
                                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Sound Group");
                                            }
                                            if (groupIndex.Value == -1) {
                                                aEvent.soundType = MasterAudio.NO_GROUP_NAME;
                                            } else {
                                                aEvent.soundType = groupNames[groupIndex.Value];
                                            }
                                        }
                                    } else {
                                        var newSoundT = EditorGUILayout.TextField("Sound Group", aEvent.soundType);
                                        if (newSoundT != aEvent.soundType) {
                                            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Sound Group");
                                            aEvent.soundType = newSoundT;
                                        }
                                    }
                                }
                            }

                            switch (aEvent.currentSoundGroupCommand) {
                                case MasterAudio.SoundGroupCommand.None:
                                    DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                                    break;
                                case MasterAudio.SoundGroupCommand.FadeToVolume:
                                    var newFadeVol = EditorGUILayout.Slider("Target Volume", aEvent.fadeVolume, 0f, 1f);
                                    if (newFadeVol != aEvent.fadeVolume) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Target Volume");
                                        aEvent.fadeVolume = newFadeVol;
                                    }

                                    var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                                    if (newFadeTime != aEvent.fadeTime) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Fade Time");
                                        aEvent.fadeTime = newFadeTime;
                                    }
                                    break;
                                case MasterAudio.SoundGroupCommand.FadeOutAllOfSound:
                                    var newFadeT = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                                    if (newFadeT != aEvent.fadeTime) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Fade Time");
                                        aEvent.fadeTime = newFadeT;
                                    }
                                    break;
                                case MasterAudio.SoundGroupCommand.FadeOutSoundGroupOfTransform:
                                    var newFade = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                                    if (newFade != aEvent.fadeTime) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Fade Time");
                                        aEvent.fadeTime = newFade;
                                    }
                                    break;
                                case MasterAudio.SoundGroupCommand.Mute:
                                    break;
                                case MasterAudio.SoundGroupCommand.Pause:
                                    break;
                                case MasterAudio.SoundGroupCommand.Solo:
                                    break;
                                case MasterAudio.SoundGroupCommand.Unmute:
                                    break;
                                case MasterAudio.SoundGroupCommand.Unpause:
                                    break;
                                case MasterAudio.SoundGroupCommand.Unsolo:
                                    break;
                            }

                            break;
                        case MasterAudio.EventSoundFunctionType.BusControl:
                            EditorGUI.indentLevel = 1;
                            var newBusCmd = (MasterAudio.BusCommand)EditorGUILayout.EnumPopup("Bus Command", aEvent.currentBusCommand);
                            if (newBusCmd != aEvent.currentBusCommand) {
                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Bus Command");
                                aEvent.currentBusCommand = newBusCmd;
                            }

                            if (aEvent.currentBusCommand != MasterAudio.BusCommand.None) {
                                var newAllTypes = EditorGUILayout.Toggle("Do For Every Bus?", aEvent.allSoundTypesForBusCmd);
                                if (newAllTypes != aEvent.allSoundTypesForBusCmd) {
                                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Do For Every Bus?");
                                    aEvent.allSoundTypesForBusCmd = newAllTypes;
                                }

                                if (!aEvent.allSoundTypesForBusCmd) {
                                    if (maInScene) {
                                        var existingIndex = busNames.IndexOf(aEvent.busName);

                                        int? busIndex = null;

                                        var noBus = false;
                                        var noMatch = false;

                                        if (existingIndex >= 1) {
                                            busIndex = EditorGUILayout.Popup("Bus Name", existingIndex, busNames.ToArray());
                                            if (existingIndex == 1) {
                                                noBus = true;
                                            }
                                        } else if (existingIndex == -1 && aEvent.busName == MasterAudio.NO_GROUP_NAME) {
                                            busIndex = EditorGUILayout.Popup("Bus Name", existingIndex, busNames.ToArray());
                                        } else { // non-match
                                            var newBusName = EditorGUILayout.TextField("Bus Name", aEvent.busName);
                                            if (newBusName != aEvent.busName) {
                                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Bus Name");
                                                aEvent.busName = newBusName;
                                            }

                                            var newIndex = EditorGUILayout.Popup("All Buses", -1, busNames.ToArray());
                                            if (newIndex >= 0) {
                                                busIndex = newIndex;
                                            }
                                            noMatch = true;
                                        }

                                        if (noBus) {
                                            DTGUIHelper.ShowRedError("No Bus Name specified. Action will do nothing.");
                                        } else if (noMatch) {
                                            DTGUIHelper.ShowRedError("Bus Name found no match. Type in or choose one.");
                                        }

                                        if (busIndex.HasValue) {
                                            if (existingIndex != busIndex.Value) {
                                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Bus");
                                            }
                                            if (busIndex.Value == -1) {
                                                aEvent.busName = MasterAudio.NO_GROUP_NAME;
                                            } else {
                                                aEvent.busName = busNames[busIndex.Value];
                                            }
                                        }
                                    } else {
                                        var newBusName = EditorGUILayout.TextField("Bus Name", aEvent.busName);
                                        if (newBusName != aEvent.busName) {
                                            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Bus Name");
                                            aEvent.busName = newBusName;
                                        }
                                    }
                                }
                            }

                            switch (aEvent.currentBusCommand) {
                                case MasterAudio.BusCommand.None:
                                    DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                                    break;
                                case MasterAudio.BusCommand.FadeToVolume:
                                    var newFadeVol = EditorGUILayout.Slider("Target Volume", aEvent.fadeVolume, 0f, 1f);
                                    if (newFadeVol != aEvent.fadeVolume) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Target Volume");
                                        aEvent.fadeVolume = newFadeVol;
                                    }

                                    var newFadeTime = EditorGUILayout.Slider("Fade Time", aEvent.fadeTime, 0f, 10f);
                                    if (newFadeTime != aEvent.fadeTime) {
                                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Fade Time");
                                        aEvent.fadeTime = newFadeTime;
                                    }
                                    break;
                                case MasterAudio.BusCommand.Pause:
                                    break;
                                case MasterAudio.BusCommand.Unpause:
                                    break;
                            }

                            break;
                        case MasterAudio.EventSoundFunctionType.CustomEventControl:
                            if (eType == EventSounds.EventType.UserDefinedEvent) {
                                DTGUIHelper.ShowRedError("Custom Event Receivers cannot fire events. Select another Action Type.");
                                break;
                            }

                            EditorGUI.indentLevel = 1;
                            var newEventCmd = (MasterAudio.CustomEventCommand)EditorGUILayout.EnumPopup("Custom Event Cmd", aEvent.currentCustomEventCommand);
                            if (newEventCmd != aEvent.currentCustomEventCommand) {
                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Custom Event Command");
                                aEvent.currentCustomEventCommand = newEventCmd;
                            }

                            switch (aEvent.currentCustomEventCommand) {
                                case MasterAudio.CustomEventCommand.None:
                                    DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                                    break;
                                case MasterAudio.CustomEventCommand.FireEvent:
                                    if (maInScene) {
                                        var existingIndex = customEventNames.IndexOf(aEvent.theCustomEventName);

                                        int? customEventIndex = null;

                                        EditorGUI.indentLevel = 1;

                                        var noEvent = false;
                                        var noMatch = false;

                                        if (existingIndex >= 1) {
                                            customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, customEventNames.ToArray());
                                            if (existingIndex == 1) {
                                                noEvent = true;
                                            }
                                        } else if (existingIndex == -1 && aEvent.soundType == MasterAudio.NO_GROUP_NAME) {
                                            customEventIndex = EditorGUILayout.Popup("Custom Event Name", existingIndex, customEventNames.ToArray());
                                        } else { // non-match
                                            noMatch = true;
                                            var newEventName = EditorGUILayout.TextField("Custom Event Name", aEvent.theCustomEventName);
                                            if (newEventName != aEvent.theCustomEventName) {
                                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Custom Event Name");
                                                aEvent.theCustomEventName = newEventName;
                                            }

                                            var newIndex = EditorGUILayout.Popup("All Custom Events", -1, customEventNames.ToArray());
                                            if (newIndex >= 0) {
                                                customEventIndex = newIndex;
                                            }
                                        }

                                        if (noEvent) {
                                            DTGUIHelper.ShowRedError("No Custom Event specified. This section will do nothing.");
                                        } else if (noMatch) {
                                            DTGUIHelper.ShowRedError("Custom Event found no match. Type in or choose one.");
                                        }

                                        if (customEventIndex.HasValue) {
                                            if (existingIndex != customEventIndex.Value) {
                                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Custom Event");
                                            }
                                            if (customEventIndex.Value == -1) {
                                                aEvent.theCustomEventName = MasterAudio.NO_GROUP_NAME;
                                            } else {
                                                aEvent.theCustomEventName = customEventNames[customEventIndex.Value];
                                            }
                                        }
                                    } else {
                                        var newCustomEvent = EditorGUILayout.TextField("Custom Event Name", aEvent.theCustomEventName);
                                        if (newCustomEvent != aEvent.theCustomEventName) {
                                            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "Custom Event Name");
                                            aEvent.theCustomEventName = newCustomEvent;
                                        }
                                    }

                                    break;
                            }

                            break;
                        case MasterAudio.EventSoundFunctionType.GlobalControl:
                            EditorGUI.indentLevel = 1;
                            var newCmd = (MasterAudio.GlobalCommand)EditorGUILayout.EnumPopup("Global Cmd", aEvent.currentGlobalCommand);
                            if (newCmd != aEvent.currentGlobalCommand) {
                                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Global Command");
                                aEvent.currentGlobalCommand = newCmd;
                            }

                            if (aEvent.currentGlobalCommand == MasterAudio.GlobalCommand.None) {
                                DTGUIHelper.ShowRedError("You have no command selected. Action will do nothing.");
                            }
                            break;
                    }

                    EditorGUI.indentLevel = 0;

                    var newEmit = EditorGUILayout.Toggle("Emit Particle", aEvent.emitParticles);
                    if (newEmit != aEvent.emitParticles) {
                        UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Emit Particle");
                        aEvent.emitParticles = newEmit;
                    }
                    if (aEvent.emitParticles) {
                        var newParticleCount = EditorGUILayout.IntSlider("Particle Count", aEvent.particleCountToEmit, 1, 100);
                        if (newParticleCount != aEvent.particleCountToEmit) {
                            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Particle Count");
                            aEvent.particleCountToEmit = newParticleCount;
                        }
                    }
                }

                switch (buttonPressed) {
                    case DTGUIHelper.DTFunctionButtons.Add:
                        indexToInsert = j + 1;
                        break;
                    case DTGUIHelper.DTFunctionButtons.Remove:
                        indexToRemove = j;
                        break;
                    case DTGUIHelper.DTFunctionButtons.ShiftUp:
                        indexToShiftUp = j;
                        break;
                    case DTGUIHelper.DTFunctionButtons.ShiftDown:
                        indexToShiftDown = j;
                        break;
                }
            }
        }

        AudioEvent item = null;

        if (indexToInsert.HasValue) {
            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "Add action");
            eventGrp.SoundEvents.Insert(indexToInsert.Value, new AudioEvent());
        } else if (indexToRemove.HasValue) {
            if (eventGrp.SoundEvents.Count <= 1) {
                DTGUIHelper.ShowAlert("You cannot delete the last Action. Disable this event if you don't need it.");
            } else {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "Delete action");
                eventGrp.SoundEvents.RemoveAt(indexToRemove.Value);
            }
        } else if (indexToShiftUp.HasValue) {
            item = eventGrp.SoundEvents[indexToShiftUp.Value];

            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "Shift up event action");

            eventGrp.SoundEvents.Insert(indexToShiftUp.Value - 1, item);
            eventGrp.SoundEvents.RemoveAt(indexToShiftUp.Value + 1);
        } else if (indexToShiftDown.HasValue) {
            var index = indexToShiftDown.Value + 1;
            item = eventGrp.SoundEvents[index];

            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "Shift down event action");

            eventGrp.SoundEvents.Insert(index - 1, item);
            eventGrp.SoundEvents.RemoveAt(index + 1);
        }

        return isDirty;
    }
Ejemplo n.º 13
0
    public override void OnInspectorGUI() {
        EditorGUIUtility.LookLikeControls();

        MasterAudio.Instance = null;

        ma = MasterAudio.Instance;
        if (ma != null) {
            DTGUIHelper.ShowHeaderTexture(MasterAudioInspectorResources.logoTexture);
        }

        isDirty = false;

        sounds = (EventSounds)target;

        maInScene = ma != null;
        if (maInScene) {
            groupNames = ma.GroupNames;
            busNames = ma.BusNames;
            playlistNames = ma.PlaylistNames;
            customEventNames = ma.CustomEventNames;
        }

        playlistControllerNames = new List<string>();
        playlistControllerNames.Add(MasterAudio.DYNAMIC_GROUP_NAME);
        playlistControllerNames.Add(MasterAudio.NO_GROUP_NAME);

#if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5
		// component doesn't exist
#else
        var anim = sounds.GetComponent<Animator>();
        hasMechanim = anim != null;
#endif

        var pcs = GameObject.FindObjectsOfType(typeof(PlaylistController));
        for (var i = 0; i < pcs.Length; i++) {
            playlistControllerNames.Add(pcs[i].name);
        }

        // populate unused Events for dropdown
        var unusedEventTypes = new List<string>();
        if (!sounds.useStartSound) {
            unusedEventTypes.Add("Start");
        }
        if (!sounds.useEnableSound) {
            unusedEventTypes.Add("Enable");
        }
        if (!sounds.useDisableSound) {
            unusedEventTypes.Add("Disable");
        }
        if (!sounds.useVisibleSound) {
            unusedEventTypes.Add("Visible");
        }
        if (!sounds.useInvisibleSound) {
            unusedEventTypes.Add("Invisible");
        }

#if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
			// these events don't exist
#else
        if (!sounds.useCollision2dSound) {
            unusedEventTypes.Add("2D Collision Enter");
        }
        if (!sounds.useCollisionExit2dSound) {
            unusedEventTypes.Add("2D Collision Exit");
        }
        if (!sounds.useTriggerEnter2dSound) {
            unusedEventTypes.Add("2D Trigger Enter");
        }
        if (!sounds.useTriggerExit2dSound) {
            unusedEventTypes.Add("2D Trigger Exit");
        }
#endif

        if (!sounds.useCollisionSound) {
            unusedEventTypes.Add("Collision Enter");
        }
        if (!sounds.useCollisionExitSound) {
            unusedEventTypes.Add("Collision Exit");
        }
        if (!sounds.useTriggerEnterSound) {
            unusedEventTypes.Add("Trigger Enter");
        }
        if (!sounds.useTriggerExitSound) {
            unusedEventTypes.Add("Trigger Exit");
        }
        if (!sounds.useParticleCollisionSound) {
            unusedEventTypes.Add("Particle Collision");
        }
        if (!sounds.useMouseEnterSound) {
            unusedEventTypes.Add("Mouse Enter");
        }
        if (!sounds.useMouseExitSound) {
            unusedEventTypes.Add("Mouse Exit");
        }
        if (!sounds.useMouseClickSound) {
            unusedEventTypes.Add("Mouse Down");
        }
        if (!sounds.useMouseDragSound) {
            unusedEventTypes.Add("Mouse Drag");
        }
        if (!sounds.useMouseUpSound) {
            unusedEventTypes.Add("Mouse Up");
        }
        if (!sounds.useNguiOnClickSound && sounds.showNGUI) {
            unusedEventTypes.Add("NGUI Mouse Click");
        }
        if (!sounds.useNguiMouseDownSound && sounds.showNGUI) {
            unusedEventTypes.Add("NGUI Mouse Down");
        }
        if (!sounds.useNguiMouseUpSound && sounds.showNGUI) {
            unusedEventTypes.Add("NGUI Mouse Up");
        }
        if (!sounds.useNguiMouseEnterSound && sounds.showNGUI) {
            unusedEventTypes.Add("NGUI Mouse Enter");
        }
        if (!sounds.useNguiMouseExitSound && sounds.showNGUI) {
            unusedEventTypes.Add("NGUI Mouse Exit");
        }
        if (!sounds.useSpawnedSound && sounds.showPoolManager) {
            unusedEventTypes.Add("Spawned");
        }
        if (!sounds.useDespawnedSound && sounds.showPoolManager) {
            unusedEventTypes.Add("Despawned");
        }

        if (hasMechanim) {
            unusedEventTypes.Add("Mechanim State Entered");
        }

        unusedEventTypes.Add("Custom Event");

        var newDisable = EditorGUILayout.Toggle("Disable Sounds", sounds.disableSounds);
        if (newDisable != sounds.disableSounds) {
            UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Disable Sounds");
            sounds.disableSounds = newDisable;
        }

        if (!sounds.disableSounds) {
            var newSpawnMode = (MasterAudio.SoundSpawnLocationMode)EditorGUILayout.EnumPopup("Sound Spawn Mode", sounds.soundSpawnMode);
            if (newSpawnMode != sounds.soundSpawnMode) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "change Sound Spawn Mode");
                sounds.soundSpawnMode = newSpawnMode;
            }

            var newGiz = EditorGUILayout.Toggle("Show 3D Gizmo", sounds.showGizmo);
            if (newGiz != sounds.showGizmo) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Show 3D Gizmo");
                sounds.showGizmo = newGiz;
            }

            var newNGUI = EditorGUILayout.Toggle("NGUI Events", sounds.showNGUI);
            if (newNGUI != sounds.showNGUI) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle NGUI Events");
                sounds.showNGUI = newNGUI;
            }

            var newPM = EditorGUILayout.Toggle("Pooling Events", sounds.showPoolManager);
            if (newPM != sounds.showPoolManager) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Pooling Events");
                sounds.showPoolManager = newPM;
            }

            var newUnused = EditorGUILayout.Toggle("Minimal Mode", sounds.hideUnused);
            if (newUnused != sounds.hideUnused) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Hide Unused Events");
                sounds.hideUnused = newUnused;
            }

            var newLogMissing = EditorGUILayout.Toggle("Log Missing Events", sounds.logMissingEvents);
            if (newLogMissing != sounds.logMissingEvents) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Log Missing Events");
                sounds.logMissingEvents = newLogMissing;
            }

            if (sounds.hideUnused) {
                var newEventIndex = EditorGUILayout.Popup("Event To Activate", -1, unusedEventTypes.ToArray());
                if (newEventIndex > -1) {
                    var selectedEvent = unusedEventTypes[newEventIndex];
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "Active Event");

                    switch (selectedEvent) {
                        case "Start":
                            sounds.useStartSound = true;
                            AddEventIfZero(sounds.startSound);
                            break;
                        case "Enable":
                            sounds.useEnableSound = true;
                            AddEventIfZero(sounds.enableSound);
                            break;
                        case "Disable":
                            sounds.useDisableSound = true;
                            AddEventIfZero(sounds.disableSound);
                            break;
                        case "Visible":
                            sounds.useVisibleSound = true;
                            AddEventIfZero(sounds.visibleSound);
                            break;
                        case "Invisible":
                            sounds.useInvisibleSound = true;
                            AddEventIfZero(sounds.invisibleSound);
                            break;
                        case "2D Collision Enter":
                            sounds.useCollision2dSound = true;
                            AddEventIfZero(sounds.collision2dSound);
                            break;
                        case "2D Collision Exit":
                            sounds.useCollisionExit2dSound = true;
                            AddEventIfZero(sounds.collisionExit2dSound);
                            break;
                        case "2D Trigger Enter":
                            sounds.useTriggerEnter2dSound = true;
                            AddEventIfZero(sounds.triggerEnter2dSound);
                            break;
                        case "2D Trigger Exit":
                            sounds.useTriggerExit2dSound = true;
                            AddEventIfZero(sounds.triggerExit2dSound);
                            break;
                        case "Collision Enter":
                            sounds.useCollisionSound = true;
                            AddEventIfZero(sounds.collisionSound);
                            break;
                        case "Collision Exit":
                            sounds.useCollisionExitSound = true;
                            AddEventIfZero(sounds.collisionExitSound);
                            break;
                        case "Trigger Enter":
                            sounds.useTriggerEnterSound = true;
                            AddEventIfZero(sounds.triggerSound);
                            break;
                        case "Trigger Exit":
                            sounds.useTriggerExitSound = true;
                            AddEventIfZero(sounds.triggerExitSound);
                            break;
                        case "Particle Collision":
                            sounds.useParticleCollisionSound = true;
                            AddEventIfZero(sounds.particleCollisionSound);
                            break;
                        case "Mouse Enter":
                            sounds.useMouseEnterSound = true;
                            AddEventIfZero(sounds.mouseEnterSound);
                            break;
                        case "Mouse Exit":
                            sounds.useMouseExitSound = true;
                            AddEventIfZero(sounds.mouseExitSound);
                            break;
                        case "Mouse Down":
                            sounds.useMouseClickSound = true;
                            AddEventIfZero(sounds.mouseClickSound);
                            break;
                        case "Mouse Drag":
                            sounds.useMouseDragSound = true;
                            AddEventIfZero(sounds.mouseDragSound);
                            break;
                        case "Mouse Up":
                            sounds.useMouseUpSound = true;
                            AddEventIfZero(sounds.mouseUpSound);
                            break;
                        case "NGUI Mouse Click":
                            sounds.useNguiOnClickSound = true;
                            AddEventIfZero(sounds.nguiOnClickSound);
                            break;
                        case "NGUI Mouse Down":
                            sounds.useNguiMouseDownSound = true;
                            AddEventIfZero(sounds.nguiMouseDownSound);
                            break;
                        case "NGUI Mouse Up":
                            sounds.useNguiMouseUpSound = true;
                            AddEventIfZero(sounds.nguiMouseUpSound);
                            break;
                        case "NGUI Mouse Enter":
                            sounds.useNguiMouseEnterSound = true;
                            AddEventIfZero(sounds.nguiMouseEnterSound);
                            break;
                        case "NGUI Mouse Exit":
                            sounds.useNguiMouseExitSound = true;
                            AddEventIfZero(sounds.nguiMouseExitSound);
                            break;
                        case "Spawned":
                            sounds.useSpawnedSound = true;
                            AddEventIfZero(sounds.spawnedSound);
                            break;
                        case "Despawned":
                            sounds.useDespawnedSound = true;
                            AddEventIfZero(sounds.despawnedSound);
                            break;
                        case "Mechanim State Entered":
                            CreateMechanimStateEntered(false);
                            break;
                        case "Custom Event":
                            CreateCustomEvent(false);
                            break;
                        default:
                            Debug.LogError("Add code for event type: " + selectedEvent);
                            break;
                    }
                }
            } else {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(154);
                GUI.contentColor = Color.green;
                if (GUILayout.Button("Add Custom Event", EditorStyles.toolbarButton, GUILayout.Width(110))) {
                    CreateCustomEvent(true);
                }
                GUI.contentColor = Color.white;
                EditorGUILayout.EndHorizontal();
            }
        }

        EditorGUILayout.Separator();
        var suffix = string.Empty;
        if (sounds.disableSounds) {
            suffix = " (DISABLED)";
        } else if (unusedEventTypes.Count > 0 && sounds.hideUnused) {
            suffix = " (" + unusedEventTypes.Count + " hidden)";
        }
        GUILayout.Label("Sound Triggers" + suffix, EditorStyles.boldLabel);

        List<bool> changedList = new List<bool>();

        // trigger sounds
        if (!sounds.hideUnused || sounds.useStartSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useStartSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);

            var newUseStart = EditorGUILayout.Toggle("Start" + DisabledText, sounds.useStartSound);
            if (newUseStart != sounds.useStartSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Start Sound");
                sounds.useStartSound = newUseStart;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useStartSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.startSound, EventSounds.EventType.OnStart));
            }
        }

        if (!sounds.hideUnused || sounds.useEnableSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useEnableSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newUseEnable = EditorGUILayout.Toggle("Enable" + DisabledText, sounds.useEnableSound);
            if (newUseEnable != sounds.useEnableSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Enable Sound");
                sounds.useEnableSound = newUseEnable;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useEnableSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.enableSound, EventSounds.EventType.OnEnable));
            }
        }

        if (!sounds.hideUnused || sounds.useDisableSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useDisableSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newDisableSound = EditorGUILayout.Toggle("Disable" + DisabledText, sounds.useDisableSound);
            if (newDisableSound != sounds.useDisableSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Disable Sound");
                sounds.useDisableSound = newDisableSound;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useDisableSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.disableSound, EventSounds.EventType.OnDisable));
            }
        }

        if (!sounds.hideUnused || sounds.useVisibleSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useVisibleSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newVisible = EditorGUILayout.Toggle("Visible" + DisabledText, sounds.useVisibleSound);
            if (newVisible != sounds.useVisibleSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Visible Sound");
                sounds.useVisibleSound = newVisible;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useVisibleSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.visibleSound, EventSounds.EventType.OnVisible));
            }
        }

        if (!sounds.hideUnused || sounds.useInvisibleSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useInvisibleSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newInvis = EditorGUILayout.Toggle("Invisible" + DisabledText, sounds.useInvisibleSound);
            if (newInvis != sounds.useInvisibleSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Invisible Sound");
                sounds.useInvisibleSound = newInvis;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useInvisibleSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.invisibleSound, EventSounds.EventType.OnInvisible));
            }
        }

#if UNITY_3_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_1 || UNITY_4_2
			// these events don't exist
#else
        if (!sounds.hideUnused || sounds.useCollision2dSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useCollision2dSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newCollision2d = EditorGUILayout.Toggle("2D Collision Enter" + DisabledText, sounds.useCollision2dSound);
            if (newCollision2d != sounds.useCollision2dSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle 2D Collision Enter Sound");
                sounds.useCollision2dSound = newCollision2d;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useCollision2dSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.collision2dSound, EventSounds.EventType.OnCollision2D));
            }
        }

        if (!sounds.hideUnused || sounds.useCollisionExit2dSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useCollisionExit2dSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newCollision2d = EditorGUILayout.Toggle("2D Collision Exit" + DisabledText, sounds.useCollisionExit2dSound);
            if (newCollision2d != sounds.useCollisionExit2dSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle 2D Collision Exit Sound");
                sounds.useCollisionExit2dSound = newCollision2d;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useCollisionExit2dSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.collisionExit2dSound, EventSounds.EventType.OnCollisionExit2D));
            }
        }

        if (!sounds.hideUnused || sounds.useTriggerEnter2dSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useTriggerEnter2dSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newTrigger2d = EditorGUILayout.Toggle("2D Trigger Enter" + DisabledText, sounds.useTriggerEnter2dSound);
            if (newTrigger2d != sounds.useTriggerEnter2dSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle 2D Trigger Enter Sound");
                sounds.useTriggerEnter2dSound = newTrigger2d;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useTriggerEnter2dSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.triggerEnter2dSound, EventSounds.EventType.OnTriggerEnter2D));
            }
        }

        if (!sounds.hideUnused || sounds.useTriggerExit2dSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useTriggerExit2dSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newTriggerExit2d = EditorGUILayout.Toggle("2D Trigger Exit" + DisabledText, sounds.useTriggerExit2dSound);
            if (newTriggerExit2d != sounds.useTriggerExit2dSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle 2D Trigger Exit Sound");
                sounds.useTriggerExit2dSound = newTriggerExit2d;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useTriggerExit2dSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.triggerExit2dSound, EventSounds.EventType.OnTriggerExit2D));
            }
        }
#endif

        if (!sounds.hideUnused || sounds.useCollisionSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useCollisionSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newCollision = EditorGUILayout.Toggle("Collision Enter" + DisabledText, sounds.useCollisionSound);
            if (newCollision != sounds.useCollisionSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Collision Enter Sound");
                sounds.useCollisionSound = newCollision;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useCollisionSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.collisionSound, EventSounds.EventType.OnCollision));
            }
        }

        if (!sounds.hideUnused || sounds.useCollisionExitSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useCollisionExitSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newCollision = EditorGUILayout.Toggle("Collision Exit" + DisabledText, sounds.useCollisionExitSound);
            if (newCollision != sounds.useCollisionExitSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Collision Exit Sound");
                sounds.useCollisionExitSound = newCollision;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useCollisionExitSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.collisionExitSound, EventSounds.EventType.OnCollisionExit));
            }
        }

        if (!sounds.hideUnused || sounds.useTriggerEnterSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useTriggerEnterSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newTrigger = EditorGUILayout.Toggle("Trigger Enter" + DisabledText, sounds.useTriggerEnterSound);
            if (newTrigger != sounds.useTriggerEnterSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Trigger Enter Sound");
                sounds.useTriggerEnterSound = newTrigger;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useTriggerEnterSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.triggerSound, EventSounds.EventType.OnTriggerEnter));
            }
        }

        if (!sounds.hideUnused || sounds.useTriggerExitSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useTriggerExitSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newTriggerExit = EditorGUILayout.Toggle("Trigger Exit" + DisabledText, sounds.useTriggerExitSound);
            if (newTriggerExit != sounds.useTriggerExitSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Trigger Exit Sound");
                sounds.useTriggerExitSound = newTriggerExit;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useTriggerExitSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.triggerExitSound, EventSounds.EventType.OnTriggerExit));
            }
        }

        if (!sounds.hideUnused || sounds.useParticleCollisionSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useParticleCollisionSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newCollision = EditorGUILayout.Toggle("Particle Collision" + DisabledText, sounds.useParticleCollisionSound);
            if (newCollision != sounds.useParticleCollisionSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Particle Collision Sound");
                sounds.useParticleCollisionSound = newCollision;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useParticleCollisionSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.particleCollisionSound, EventSounds.EventType.OnParticleCollision));
            }
        }

        if (!sounds.hideUnused || sounds.useMouseEnterSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useMouseEnterSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newMouseEnter = EditorGUILayout.Toggle("Mouse Enter" + DisabledText, sounds.useMouseEnterSound);
            if (newMouseEnter != sounds.useMouseEnterSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Mouse Enter Sound");
                sounds.useMouseEnterSound = newMouseEnter;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useMouseEnterSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.mouseEnterSound, EventSounds.EventType.OnMouseEnter));
            }
        }

        if (!sounds.hideUnused || sounds.useMouseExitSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useMouseExitSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newMouseEnter = EditorGUILayout.Toggle("Mouse Exit" + DisabledText, sounds.useMouseExitSound);
            if (newMouseEnter != sounds.useMouseExitSound) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Mouse Exit Sound");
                sounds.useMouseExitSound = newMouseEnter;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useMouseExitSound && !sounds.disableSounds) {
                changedList.Add(RenderAudioEvent(sounds.mouseExitSound, EventSounds.EventType.OnMouseExit));
            }
        }

        if (!sounds.hideUnused || sounds.useMouseClickSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useMouseClickSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newMouseClick = EditorGUILayout.Toggle("Mouse Down" + DisabledText, sounds.useMouseClickSound);
            if (newMouseClick != sounds.useMouseClickSound) {
                sounds.useMouseClickSound = newMouseClick;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useMouseClickSound && !sounds.disableSounds) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Mouse Down Sound");
                changedList.Add(RenderAudioEvent(sounds.mouseClickSound, EventSounds.EventType.OnMouseClick));
            }
        }

        if (!sounds.hideUnused || sounds.useMouseDragSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useMouseDragSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newMouseClick = EditorGUILayout.Toggle("Mouse Drag" + DisabledText, sounds.useMouseDragSound);
            if (newMouseClick != sounds.useMouseDragSound) {
                sounds.useMouseDragSound = newMouseClick;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useMouseDragSound && !sounds.disableSounds) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Mouse Drag Sound");
                changedList.Add(RenderAudioEvent(sounds.mouseDragSound, EventSounds.EventType.OnMouseDrag));
            }
        }

        if (!sounds.hideUnused || sounds.useMouseUpSound) {
            EditorGUI.indentLevel = 0;
            GUI.color = sounds.useMouseUpSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
            EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
            var newMouseClick = EditorGUILayout.Toggle("Mouse Up" + DisabledText, sounds.useMouseUpSound);
            if (newMouseClick != sounds.useMouseUpSound) {
                sounds.useMouseUpSound = newMouseClick;
            }
            EditorGUILayout.EndHorizontal();
            GUI.color = Color.white;
            if (sounds.useMouseUpSound && !sounds.disableSounds) {
                UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Mouse Up Sound");
                changedList.Add(RenderAudioEvent(sounds.mouseUpSound, EventSounds.EventType.OnMouseUp));
            }
        }

        if (sounds.showNGUI) {
            if (!sounds.hideUnused || sounds.useNguiOnClickSound) {
                EditorGUI.indentLevel = 0;
                GUI.color = sounds.useNguiOnClickSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newMouseClick = EditorGUILayout.Toggle("NGUI Mouse Click" + DisabledText, sounds.useNguiOnClickSound);
                if (newMouseClick != sounds.useNguiOnClickSound) {
                    sounds.useNguiOnClickSound = newMouseClick;
                }
                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;
                if (sounds.useNguiOnClickSound && !sounds.disableSounds) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle NGUI Mouse Click Sound");
                    changedList.Add(RenderAudioEvent(sounds.nguiOnClickSound, EventSounds.EventType.NGUIOnClick));
                }
            }

            if (!sounds.hideUnused || sounds.useNguiMouseDownSound) {
                EditorGUI.indentLevel = 0;
                GUI.color = sounds.useNguiMouseDownSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newMouseClick = EditorGUILayout.Toggle("NGUI Mouse Down" + DisabledText, sounds.useNguiMouseDownSound);
                if (newMouseClick != sounds.useNguiMouseDownSound) {
                    sounds.useNguiMouseDownSound = newMouseClick;
                }
                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;
                if (sounds.useNguiMouseDownSound && !sounds.disableSounds) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle NGUI Mouse Down Sound");
                    changedList.Add(RenderAudioEvent(sounds.nguiMouseDownSound, EventSounds.EventType.NGUIMouseDown));
                }
            }

            if (!sounds.hideUnused || sounds.useNguiMouseUpSound) {
                EditorGUI.indentLevel = 0;
                GUI.color = sounds.useNguiMouseUpSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newMouseClick = EditorGUILayout.Toggle("NGUI Mouse UP" + DisabledText, sounds.useNguiMouseUpSound);
                if (newMouseClick != sounds.useNguiMouseUpSound) {
                    sounds.useNguiMouseUpSound = newMouseClick;
                }
                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;
                if (sounds.useNguiMouseUpSound && !sounds.disableSounds) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle NGUI Mouse UP Sound");
                    changedList.Add(RenderAudioEvent(sounds.nguiMouseUpSound, EventSounds.EventType.NGUIMouseUp));
                }
            }

            if (!sounds.hideUnused || sounds.useNguiMouseEnterSound) {
                EditorGUI.indentLevel = 0;
                GUI.color = sounds.useNguiMouseEnterSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newMouseClick = EditorGUILayout.Toggle("NGUI Mouse Enter" + DisabledText, sounds.useNguiMouseEnterSound);
                if (newMouseClick != sounds.useNguiMouseEnterSound) {
                    sounds.useNguiMouseEnterSound = newMouseClick;
                }
                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;
                if (sounds.useNguiMouseEnterSound && !sounds.disableSounds) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle NGUI Mouse Enter Sound");
                    changedList.Add(RenderAudioEvent(sounds.nguiMouseEnterSound, EventSounds.EventType.NGUIMouseEnter));
                }
            }

            if (!sounds.hideUnused || sounds.useNguiMouseExitSound) {
                EditorGUI.indentLevel = 0;
                GUI.color = sounds.useNguiMouseExitSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newMouseClick = EditorGUILayout.Toggle("NGUI Mouse Exit" + DisabledText, sounds.useNguiMouseExitSound);
                if (newMouseClick != sounds.useNguiMouseExitSound) {
                    sounds.useNguiMouseExitSound = newMouseClick;
                }
                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;
                if (sounds.useNguiMouseExitSound && !sounds.disableSounds) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle NGUI Mouse Exit Sound");
                    changedList.Add(RenderAudioEvent(sounds.nguiMouseExitSound, EventSounds.EventType.NGUIMouseExit));
                }
            }
        }

        if (sounds.showPoolManager) {
            if (!sounds.hideUnused || sounds.useSpawnedSound) {
                EditorGUI.indentLevel = 0;
                GUI.color = sounds.useSpawnedSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newSpawned = EditorGUILayout.Toggle("Spawned (Pooling)" + DisabledText, sounds.useSpawnedSound);
                if (newSpawned != sounds.useSpawnedSound) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Spawned Sound");
                    sounds.useSpawnedSound = newSpawned;
                }
                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;
                if (sounds.useSpawnedSound && !sounds.disableSounds) {
                    changedList.Add(RenderAudioEvent(sounds.spawnedSound, EventSounds.EventType.OnSpawned));
                }
            }

            if (!sounds.hideUnused || sounds.useDespawnedSound) {
                EditorGUI.indentLevel = 0;
                GUI.color = sounds.useDespawnedSound ? MasterAudioInspector.activeClr : MasterAudioInspector.inactiveClr;
                EditorGUILayout.BeginHorizontal(EditorStyles.objectFieldThumb);
                var newDespawned = EditorGUILayout.Toggle("Despawned (Pooling)" + DisabledText, sounds.useDespawnedSound);
                if (newDespawned != sounds.useDespawnedSound) {
                    UndoHelper.RecordObjectPropertyForUndo(ref isDirty, sounds, "toggle Despawned Sound");
                    sounds.useDespawnedSound = newDespawned;
                }
                EditorGUILayout.EndHorizontal();
                GUI.color = Color.white;
                if (sounds.useDespawnedSound && !sounds.disableSounds) {
                    changedList.Add(RenderAudioEvent(sounds.despawnedSound, EventSounds.EventType.OnDespawned));
                }
            }
        }

        if (sounds.mechanimStateChangedSounds.Count > 0) {
            EditorGUI.indentLevel = 0;

            for (var i = 0; i < sounds.mechanimStateChangedSounds.Count; i++) {
                var mechEvt = sounds.mechanimStateChangedSounds[i];

                changedList.Add(RenderAudioEvent(mechEvt, EventSounds.EventType.MechanimStateChanged, i));
            }
        }

        if (sounds.userDefinedSounds.Count > 0) {
            EditorGUI.indentLevel = 0;

            for (var i = 0; i < sounds.userDefinedSounds.Count; i++) {
                var customEventGrp = sounds.userDefinedSounds[i];

                changedList.Add(RenderAudioEvent(customEventGrp, EventSounds.EventType.UserDefinedEvent, i));
            }
        }

        if (GUI.changed || isDirty || changedList.Contains(true)) {
            EditorUtility.SetDirty(target);
        }

        //DrawDefaultInspector();
    }
Ejemplo n.º 14
0
        internal static string InsertGuaDiv(string code)
        {
            AppVars.CodeAddress = code;
            if (!string.IsNullOrEmpty(AppVars.CodeAddress))
            {
                if (AppVars.Profile.DoGuamod)
                {
                    AppVars.FightLink = "????";
                }

                if (!AppVars.Profile.DoGuamod)
                {
                    if (AppVars.MainForm != null && AppVars.MainForm.TrayIsDigitsWaitTooLong())
                    {
                        try
                        {
                            if (AppVars.MainForm != null)
                            {
                                AppVars.MainForm.BeginInvoke(
                                    new UpdateGuamodTurnOnDelegate(AppVars.MainForm.UpdateGuamodTurnOn),
                                    new object[] { });
                            }
                        }
                        catch (InvalidOperationException)
                        {
                        }
                    }
                    else
                    {
                        EventSounds.PlayDigits();
                        try
                        {
                            if (AppVars.MainForm != null)
                            {
                                AppVars.MainForm.BeginInvoke(
                                    new UpdateTrayFlashDelegate(AppVars.MainForm.UpdateTrayFlash),
                                    new object[] { "Ввод цифр" });
                            }
                        }
                        catch (InvalidOperationException)
                        {
                        }
                    }

                    try
                    {
                        if (AppVars.MainForm != null)
                        {
                            AppVars.MainForm.BeginInvoke(
                                new UpdateTrayFlashDelegate(AppVars.MainForm.UpdateTrayFlash),
                                new object[] { "Ввод цифр" });
                        }
                    }
                    catch (InvalidOperationException)
                    {
                    }
                }
            }

            return(AppVars.Profile.DoGuamod ? @"<br><img src=http://image.neverlands.ru/1x1.gif width=1 height=8><br><span id=guamod3><font class=nickname><font color=#004A7F><b>* * * *</b></font></font></span>" : string.Empty);
        }
Ejemplo n.º 15
0
        private static void FilterGetWalkers(string html)
        {
            if (!AppVars.DoShowWalkers)
            {
                return;
            }

            var mLocnow = HelperStrings.SubString(html, "<font class=placename><b>", "</b>");

            if (string.IsNullOrEmpty(mLocnow))
            {
                return;
            }

            var arg = HelperStrings.SubString(html, "new Array(", ");");

            if (string.IsNullOrEmpty(arg))
            {
                return;
            }

            var par = arg.Split(new[] { @"""," }, StringSplitOptions.RemoveEmptyEntries);

            if (par.Length == 0)
            {
                return;
            }

            var mDnow = new Dictionary <string, string>();

            for (var i = 0; i < par.Length; i++)
            {
                var pararg = par[i].Substring(3, par[i].Length - 3);
                var pars   = pararg.Split(':');
                if (pars.Length < 3)
                {
                    continue;
                }

                if (pars[1].IndexOf("<i>", StringComparison.OrdinalIgnoreCase) == -1)
                {
                    mDnow.Add(pars[1], pararg);
                }
            }

            if ((AppVars.Profile.MapLocation == AppVars.MyCoordOld) && (mLocnow == AppVars.MyLocOld))
            {
                var myDleft = new Dictionary <string, string>();
                var keyleft = AppVars.MyCharsOld.Keys;
                foreach (var kl in keyleft)
                {
                    if (kl != null && !mDnow.ContainsKey(kl))
                    {
                        if (kl.Equals(AppVars.Profile.UserNick, StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (AppVars.MainForm != null)
                            {
                                AppVars.MainForm.WriteChatMsgSafe("<b><font color=#01A9DB>Мы ушли в невид</font></b>");
                            }
                        }
                        else
                        {
                            myDleft.Add(kl, AppVars.MyCharsOld[kl]);
                        }
                    }
                }

                var myDcome = new Dictionary <string, string>();
                var keycome = mDnow.Keys;
                foreach (var kc in keycome)
                {
                    if (kc != null && !AppVars.MyCharsOld.ContainsKey(kc))
                    {
                        if (kc.Equals(AppVars.Profile.UserNick, StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (AppVars.MainForm != null)
                            {
                                AppVars.MainForm.WriteChatMsgSafe("<b><font color=#DF0101>Мы вышли из невида!</font></b>");
                            }
                        }
                        else
                        {
                            myDcome.Add(kc, mDnow[kc]);
                        }
                    }
                }

                var diffn = AppVars.MyNevids - AppVars.MyNevidsOld;
                if ((myDleft.Count != 0) || (myDcome.Count != 0) || (diffn != 0))
                {
                    var sb = new StringBuilder();
                    var i  = 0;
                    if (diffn > 0)
                    {
                        i = 1;
                        sb.Append("<font color=#5D7C91><b>");
                        if (diffn == 1)
                        {
                            sb.Append("Невидимка");
                        }
                        else
                        {
                            sb.Append(diffn);
                            sb.Append(" невидимок");
                        }

                        sb.Append("</b></font>");
                    }

                    if (myDcome.Count > 0)
                    {
                        keycome = myDcome.Keys;

                        foreach (var kc in keycome)
                        {
                            if (i > 0)
                            {
                                sb.Append(", ");
                            }

                            i++;
                            sb.Append(HtmlChar(myDcome[kc]));
                        }
                    }

                    if (i > 0)
                    {
                        sb.Append(i > 1 ? " приходят в локацию" : " приходит в локацию");
                    }

                    AppVars.MyWalkers1 = sb.ToString();
                    sb.Length          = 0;
                    i = 0;
                    if (diffn < 0)
                    {
                        i = 1;
                        sb.Append("<font color=#5D7C91><b>");
                        if (diffn == -1)
                        {
                            sb.Append("Невидимка");
                        }
                        else
                        {
                            sb.Append(-diffn);
                            sb.Append(" невидимок");
                        }

                        sb.Append("</b></font>");
                    }

                    if (myDleft.Count > 0)
                    {
                        keyleft = myDleft.Keys;

                        foreach (var kl in keyleft)
                        {
                            if (i > 0)
                            {
                                sb.Append(", ");
                            }

                            i++;
                            sb.Append(HtmlChar(myDleft[kl]));
                        }
                    }

                    if (i > 0)
                    {
                        sb.Append(i > 1 ? " покидают локацию" : " покидает локацию");
                    }

                    AppVars.MyWalkers2 = sb.ToString();
                }
            }

            AppVars.MyCoordOld = AppVars.Profile.MapLocation;
            AppVars.MyLocOld   = mLocnow;
            AppVars.MyCharsOld.Clear();
            AppVars.MyCharsOld  = new Dictionary <string, string>(mDnow);
            AppVars.MyNevidsOld = AppVars.MyNevids;

            if (!string.IsNullOrEmpty(AppVars.MyWalkers1))
            {
                EventSounds.PlayAlarm();
                try
                {
                    if (AppVars.MainForm != null)
                    {
                        AppVars.MainForm.BeginInvoke(
                            new UpdateChatDelegate(AppVars.MainForm.UpdateChat), AppVars.MyWalkers1);
                    }
                }
                catch (InvalidOperationException)
                {
                }

                AppVars.MyWalkers1 = string.Empty;
            }

            if (!string.IsNullOrEmpty(AppVars.MyWalkers2))
            {
                try
                {
                    if (AppVars.MainForm != null)
                    {
                        AppVars.MainForm.BeginInvoke(
                            new UpdateChatDelegate(AppVars.MainForm.UpdateChat),
                            new object[] { AppVars.MyWalkers2 });
                    }
                }
                catch (InvalidOperationException)
                {
                }

                AppVars.MyWalkers2 = string.Empty;
            }
        }
Ejemplo n.º 16
0
    private void RenderEventWithHeader(string text, string undoText, AudioEventGroup grp, EventSounds.EventType eType, int? itemIndex = null)
    {
        EditorGUI.indentLevel = 0;

        var state = grp.isExpanded;

        // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
        if (!state) {
            GUI.backgroundColor = DTGUIHelper.InactiveHeaderColor;
        } else {
            GUI.backgroundColor = DTGUIHelper.ActiveHeaderColor;
        }

        GUILayout.BeginHorizontal();

        #if UNITY_3_5_7
        if (!state) {
            text += " (Click to expand)";
        }
        #else
        text = "<b><size=11>" + text + "</size></b>";
        #endif
        if (state) {
            text = "\u25BC " + text;
        } else {
            text = "\u25BA " + text;
        }
        if (!GUILayout.Toggle(true, text, "dragtab", GUILayout.MinWidth(20f))) {
            state = !state;
        }

        GUILayout.Space(2f);

        switch (eType) {
            case EventSounds.EventType.MechanimStateChanged:
                if (DTGUIHelper.AddDeleteIcon(false, "Mechanim State Entered Trigger") == DTGUIHelper.DTFunctionButtons.Remove) {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                        "delete Mechanim State Entered Sound");
                    // ReSharper disable once PossibleInvalidOperationException
                    _sounds.mechanimStateChangedSounds.RemoveAt(itemIndex.Value);
                    grp.mechanimEventActive = false;
                }
                break;
            case EventSounds.EventType.UserDefinedEvent:
                if (DTGUIHelper.AddDeleteIcon(false, "Custom Event Trigger") == DTGUIHelper.DTFunctionButtons.Remove) {
                    AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds,
                        "delete Custom Event Sound");
                    // ReSharper disable once PossibleInvalidOperationException
                    _sounds.userDefinedSounds.RemoveAt(itemIndex.Value);
                    grp.customSoundActive = false;
                }
                break;
            default:
                if (DTGUIHelper.AddDeleteIcon(false, "Trigger") == DTGUIHelper.DTFunctionButtons.Remove) {
                    switch (eType) {
                        case EventSounds.EventType.NGUIMouseDown:
                            _sounds.useNguiMouseDownSound = false;
                            break;
                        case EventSounds.EventType.NGUIMouseEnter:
                            _sounds.useNguiMouseEnterSound = false;
                            break;
                        case EventSounds.EventType.NGUIMouseExit:
                            _sounds.useNguiMouseExitSound = false;
                            break;
                        case EventSounds.EventType.NGUIMouseUp:
                            _sounds.useNguiMouseUpSound = false;
                            break;
                        case EventSounds.EventType.NGUIOnClick:
                            _sounds.useNguiOnClickSound = false;
                            break;
                        case EventSounds.EventType.OnCollision:
                            _sounds.useCollisionSound = false;
                            break;
                        case EventSounds.EventType.OnCollision2D:
                            _sounds.useCollision2dSound = false;
                            break;
                        case EventSounds.EventType.OnCollisionExit:
                            _sounds.useCollisionExitSound = false;
                            break;
                        case EventSounds.EventType.OnCollisionExit2D:
                            _sounds.useCollisionExit2dSound = false;
                            break;
                        case EventSounds.EventType.OnDespawned:
                            _sounds.useDespawnedSound = false;
                            break;
                        case EventSounds.EventType.OnDisable:
                            _sounds.useDisableSound = false;
                            break;
                        case EventSounds.EventType.OnEnable:
                            _sounds.useEnableSound = false;
                            break;
                        case EventSounds.EventType.OnInvisible:
                            _sounds.useInvisibleSound = false;
                            break;
                        case EventSounds.EventType.OnMouseClick:
                            _sounds.useMouseClickSound = false;
                            break;
                        case EventSounds.EventType.OnMouseDrag:
                            _sounds.useMouseDragSound = false;
                            break;
                        case EventSounds.EventType.OnMouseEnter:
                            _sounds.useMouseEnterSound = false;
                            break;
                        case EventSounds.EventType.OnMouseExit:
                            _sounds.useMouseExitSound = false;
                            break;
                        case EventSounds.EventType.OnMouseUp:
                            _sounds.useMouseUpSound = false;
                            break;
                        case EventSounds.EventType.OnParticleCollision:
                            _sounds.useParticleCollisionSound = false;
                            break;
                        case EventSounds.EventType.OnSpawned:
                            _sounds.useSpawnedSound = false;
                            break;
                        case EventSounds.EventType.OnStart:
                            _sounds.useStartSound = false;
                            break;
                        case EventSounds.EventType.OnTriggerEnter:
                            _sounds.useTriggerEnterSound = false;
                            break;
                        case EventSounds.EventType.OnTriggerEnter2D:
                            _sounds.useTriggerEnter2dSound = false;
                            break;
                        case EventSounds.EventType.OnTriggerExit:
                            _sounds.useTriggerExitSound = false;
                            break;
                        case EventSounds.EventType.OnTriggerExit2D:
                            _sounds.useTriggerExit2dSound = false;
                            break;
                        case EventSounds.EventType.OnVisible:
                            _sounds.useVisibleSound = false;
                            break;
                        case EventSounds.EventType.UnityBeginDrag:
                            _sounds.useUnityBeginDragSound = false;
                            break;
                        case EventSounds.EventType.UnityButtonClicked:
                            _sounds.useUnityButtonClickedSound = false;
                            break;
                        case EventSounds.EventType.UnityCancel:
                            _sounds.useUnityCancelSound = false;
                            break;
                        case EventSounds.EventType.UnityDeselect:
                            _sounds.useUnityDeselectSound = false;
                            break;
                        case EventSounds.EventType.UnityDrag:
                            _sounds.useUnityDragSound = false;
                            break;
                        case EventSounds.EventType.UnityDrop:
                            _sounds.useUnityDropSound = false;
                            break;
                        case EventSounds.EventType.UnityEndDrag:
                            _sounds.useUnityEndDragSound = false;
                            break;
                        case EventSounds.EventType.UnityInitializePotentialDrag:
                            _sounds.useUnityInitializePotentialDragSound = false;
                            break;
                        case EventSounds.EventType.UnityMove:
                            _sounds.useUnityMoveSound = false;
                            break;
                        case EventSounds.EventType.UnityPointerDown:
                            _sounds.useUnityPointerDownSound = false;
                            break;
                        case EventSounds.EventType.UnityPointerEnter:
                            _sounds.useUnityPointerEnterSound = false;
                            break;
                        case EventSounds.EventType.UnityPointerExit:
                            _sounds.useUnityPointerExitSound = false;
                            break;
                        case EventSounds.EventType.UnityPointerUp:
                            _sounds.useUnityPointerUpSound = false;
                            break;
                        case EventSounds.EventType.UnityScroll:
                            _sounds.useUnityScrollSound = false;
                            break;
                        case EventSounds.EventType.UnitySelect:
                            _sounds.useUnitySelectSound = false;
                            break;
                        case EventSounds.EventType.UnitySliderChanged:
                            _sounds.useUnitySliderChangedSound = false;
                            break;
                        case EventSounds.EventType.UnitySubmit:
                            _sounds.useUnitySubmitSound = false;
                            break;
                        case EventSounds.EventType.UnityUpdateSelected:
                            _sounds.useUnityUpdateSelectedSound = false;
                            break;
                        case EventSounds.EventType.UnityToggle:
                            _sounds.useUnityToggleSound = false;
                            break;
                        default:
                            Debug.LogError("Add code to delete: " + eType);
                            break;
                    }
                }

                break;
        }

        GUILayout.Space(4f);
        DTGUIHelper.AddHelpIcon("https://dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/EventSounds.htm#EventSettings");

        GUILayout.EndHorizontal();
        GUI.backgroundColor = Color.white;
        if (!state) {
            GUILayout.Space(3f);
        }

        if (state != grp.isExpanded) {
            AudioUndoHelper.RecordObjectPropertyForUndo(ref _isDirty, _sounds, undoText);
            grp.isExpanded = state;
        }

        if (grp.isExpanded && !_sounds.disableSounds) {
            _changedList.Add(RenderAudioEvent(grp, eType));
        }

        DTGUIHelper.VerticalSpace(2);
    }
Ejemplo n.º 17
0
        internal static string ChatFilter(string message)
        {
            var xpstr = HelperStrings.SubString(message, "Получено <font color=#CC0000>боевого</font> опыта: <b><font color=#CC0000>", "</font></b>.");

            if (!string.IsNullOrEmpty(xpstr))
            {
                long xp;
                if (long.TryParse(xpstr, out xp))
                {
                    try
                    {
                        if (AppVars.MainForm != null)
                        {
                            AppVars.MainForm.BeginInvoke(
                                new UpdateXPIncDelegate(AppVars.MainForm.UpdateXPInc),
                                new object[] { xp });
                        }
                    }
                    catch (InvalidOperationException)
                    {
                    }
                }
            }

            // <font class=chattime>&nbsp;23:56:08&nbsp;</font>
            // Результат обыска бота: <B>Денежные средства «19 NV», Денежные средства «30 NV»</B>.
            // Результат обыска бота: <B>Вещь «Кинжал Разбойника»</B>.

            //message =
            //    "<font class=chattime>&nbsp;23:56:08&nbsp;</font> <font color=000000><B><font color=#CC0000>Внимание!</font> Системная информация.</B> Результат обыска бота: <B>Денежные средства «19 NV», Денежные средства «30 NV»</B>.</font><br>";

            var thingstr = HelperStrings.SubString(message, "Результат обыска бота: <B>", "</B>.");

            if (!string.IsNullOrEmpty(thingstr))
            {
                var timestr = HelperStrings.SubString(message, "<font class=chattime>&nbsp;", "&nbsp;</font> <font color=000000><B><font color=#CC0000>Внимание!</font> Системная информация.</B> Результат обыска бота: ");
                if (!string.IsNullOrEmpty(timestr))
                {
                    var          thinglist = new List <string>();
                    const string pattern   = @"«([^»]+)»";
                    foreach (Match match in Regex.Matches(thingstr, pattern))
                    {
                        thinglist.Add(match.ToString().Trim(new[] { '«', '»' }));
                    }

                    if (thinglist.Count > 0)
                    {
                        try
                        {
                            if (AppVars.MainForm != null)
                            {
                                AppVars.MainForm.BeginInvoke(
                                    new UpdateThingIncDelegate(AppVars.MainForm.UpdateThingInc),
                                    new object[] { timestr, thinglist });
                            }
                        }
                        catch (InvalidOperationException)
                        {
                        }
                    }
                }
            }

            // <font class=clchattime>&nbsp;16:45:54&nbsp;</font> >>> <SPAN alt="%Josaphina">Josaphina</SPAN>  > clan: > <SPAN alt="%Josaphina">Райская Птица</SPAN>: <font color=CC0099>+</font>

            if (message.IndexOf("<font color=#000000><b>Системная информация.</b></font> Поединок завершён.", StringComparison.OrdinalIgnoreCase) != -1)
            {
                // Конец боя
                if (!string.IsNullOrEmpty(AppVars.LastBoiLog) &&
                    !string.IsNullOrEmpty(AppVars.LastBoiSostav) &&
                    !string.IsNullOrEmpty(AppVars.LastBoiTravm) &&
                    !string.IsNullOrEmpty(AppVars.LastBoiUron))
                {
                    var newLog =
                        "Бой" +
                        AppVars.LastBoiTravm +
                        " против " +
                        AppVars.LastBoiSostav +
                        @" завершен (<a href=http://www.neverlands.ru/logs.fcg?fid=" +
                        AppVars.LastBoiLog +
                        @" onclick=""window.open(this.href);"">лог</a> боя). Нанесено урона: <FONT color=#339900><b>" +
                        AppVars.LastBoiUron +
                        "</b></FONT>";

                    /*@" target=_blank>лог</a> боя). Нанесено урона: <FONT color=#339900><b>" +*/
                    /*@" onclick=""window.open(this.href);"">лог</a> боя). Нанесено урона: <FONT color=#339900><b>" +*/

                    message = message.Replace("Поединок завершён", newLog);
                    var pos = message.IndexOf("Получено <font color=#004BBB>магического", StringComparison.OrdinalIgnoreCase);
                    if (pos != -1)
                    {
                        const string se   = "</font></b>.";
                        var          spos = message.IndexOf(se, pos, StringComparison.OrdinalIgnoreCase);
                        if (spos != -1)
                        {
                            message = message.Remove(pos, spos + se.Length - pos);
                        }
                    }

                    var texlogMessage =
                        "Бой против " +
                        AppVars.LastBoiSostav +
                        @" завершен (" +
                        AppVars.LastBoiLog +
                        @")";
                    try
                    {
                        if (AppVars.MainForm != null)
                        {
                            AppVars.MainForm.BeginInvoke(
                                new UpdateTexLogDelegate(AppVars.MainForm.UpdateTexLog),
                                new object[] { texlogMessage });
                        }
                    }
                    catch (InvalidOperationException)
                    {
                    }

                    AppVars.LastBoiLog    = string.Empty;
                    AppVars.LastBoiSostav = string.Empty;
                }
            }
            else
            {
                /*
                 * message = "<font class=prchattime>&nbsp;11:22:41&nbsp;</font> >>> <SPAN alt=\"%МасКит\">МасКит</SPAN>  > <SPAN alt=\"%Умник\">Умник</SPAN>: <font color=000000>хай</font> ";
                 * message = "<font class=yochattime>&nbsp;10:46:03&nbsp;</font> <SPAN>МасКит</SPAN>&nbsp;для <SPAN alt=\"Умник\">Умник</SPAN>: <font color=000000>я, а что?</font> ";
                 * message = "<font class=clchattime>&nbsp;16:45:54&nbsp;</font> >>> <SPAN alt=\"%Josaphina\">Josaphina</SPAN>  > clan: > <SPAN alt=\"%Умник\">Умник</SPAN>: <font color=CC0099>+</font> ";
                 */

                var posSpanEnd = message.IndexOf(@""">" + AppVars.Profile.UserNick + "</SPAN>", StringComparison.OrdinalIgnoreCase);
                if (posSpanEnd != -1)
                {
                    const string strSpanStart = "<SPAN title=\"";
                    const string strSpanEnd   = "\">";
                    var          fromNick     = HelperStrings.SubString(message, strSpanStart, strSpanEnd).TrimStart(new[] { '%' });
                    if (!fromNick.Equals(AppVars.Profile.UserNick, StringComparison.OrdinalIgnoreCase))
                    {
                        EventSounds.PlaySndMsg();
                        var istoclan = message.IndexOf(" > clan: ", StringComparison.OrdinalIgnoreCase) != -1;
                        var istopair = message.IndexOf(" > pair: ", StringComparison.OrdinalIgnoreCase) != -1;
                        if (AppVars.Profile.DoAutoAnswer)
                        {
                            var answer = "%<" + fromNick + "> " + AutoAnswerMachine.GetNextAnswer();
                            if (istoclan)
                            {
                                answer = answer.Insert(0, "%clan%");
                            }
                            else
                            if (istopair)
                            {
                                answer = answer.Insert(0, "%pair%");
                            }

                            Chat.AddAnswer(answer);
                        }
                    }
                }

                if (AppVars.Profile.DoChatLevels)
                {
                    posSpanEnd = message.IndexOf("</SPAN>", StringComparison.OrdinalIgnoreCase);
                    if (posSpanEnd != -1)
                    {
                        var posSpanTagEnd = message.LastIndexOf('>', posSpanEnd);
                        if (posSpanTagEnd != -1)
                        {
                            var sayNick = message.Substring(posSpanTagEnd + 1, posSpanEnd - posSpanTagEnd - 1);
                            if (ChatUsersManager.Exists(sayNick))
                            {
                                var posSpanTagStart = message.LastIndexOf('<', posSpanTagEnd);
                                if (posSpanTagStart != -1)
                                {
                                    var chatUser = ChatUsersManager.GetUserData(sayNick);
                                    if (!string.IsNullOrEmpty(chatUser.Level))
                                    {
                                        message = message.Insert(posSpanEnd + "</SPAN>".Length,
                                                                 "&nbsp;[" + chatUser.Level +
                                                                 @"]<a href=""http://www.neverlands.ru/pinfo.cgi?" +
                                                                 chatUser.Nick +
                                                                 @""" onclick=""window.open(this.href);""><img src=http://image.neverlands.ru/chat/info.gif width=11 height=12 border=0 align=bottom></a>");
                                    }

                                    var sb = new StringBuilder();
                                    if (!string.IsNullOrEmpty(chatUser.Sign))
                                    {
                                        sb.Append("<img src=http://image.neverlands.ru/signs/");
                                        sb.Append(chatUser.Sign);
                                        sb.Append(@" width=15 height=12 align=bottom title=""");
                                        sb.Append(chatUser.Status);
                                        sb.Append(@""">&nbsp;");
                                    }

                                    message = message.Insert(posSpanTagStart, sb.ToString());
                                }
                            }
                        }
                    }
                }
            }

            // >>> <SPAN alt="%Not Alone">Not Alone</SPAN>  > clan: > <SPAN alt="%Not Alone">Райская Птица</SPAN>:

            if (message.IndexOf("pair:", StringComparison.OrdinalIgnoreCase) != -1)
            {
                message = message.Replace("<SPAN title=\"%", "<SPAN title=\"%%%");
            }
            else
            {
                if (message.IndexOf("clan:", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    message = message.Replace("<SPAN title=\"%", "<SPAN title=\"%%");
                }
            }

            do
            {
                var pos1 = message.IndexOf("[[[", StringComparison.Ordinal);
                if (pos1 == -1)
                {
                    break;
                }

                var pos2 = message.IndexOf("]]]", pos1, StringComparison.Ordinal);
                if (pos2 == -1)
                {
                    break;
                }

                var    sorig = message.Substring(pos1 + 3, pos2 - pos1 - 3);
                string msg   = string.Empty;
                if (!sorig.Contains(":"))
                {
                    msg =
                        $"<a href=http://www.neverlands.ru/logs.fcg?fid={sorig} onclick=\"window.open(this.href);\">лог</a> боя";
                }

                message = string.Concat(message.Substring(0, pos1), msg, message.Substring(pos2 + 3));
            } while (true);

            Chat.AddStringToChat(message);
            return(message);
        }
Ejemplo n.º 18
0
        private static string MainPhpAutoFishPrepare(string html)
        {
            var p1 = html.IndexOf(AppConsts.HtmlValueRiba, StringComparison.OrdinalIgnoreCase);

            if (p1 == -1)
            {
                return(string.Empty);
            }

            AppVars.CodeAddress = string.Empty;
            var pcode = html.IndexOf(AppConsts.HtmlCodePhp, StringComparison.OrdinalIgnoreCase);

            if (pcode != -1)
            {
                pcode += AppConsts.HtmlCodePhp.Length;
                var pe = html.IndexOf('"', pcode);
                if (pe == -1)
                {
                    return(string.Empty);
                }

                AppVars.CodeAddress = AppConsts.HtmlCodePhpFull + html.Substring(pcode, pe - pcode);
            }

            var getid = HelperStrings.SubString(html, "=get_id value=", ">");

            if (string.IsNullOrEmpty(getid))
            {
                return(string.Empty);
            }

            var act = HelperStrings.SubString(html, "=act value=", ">");

            if (string.IsNullOrEmpty(act))
            {
                return(string.Empty);
            }

            var vcode = HelperStrings.SubString(html, "=vcode value=", ">");

            if (string.IsNullOrEmpty(vcode))
            {
                return(string.Empty);
            }

            var lakeid = HelperStrings.SubString(html, "=lakeid value=", ">");

            if (string.IsNullOrEmpty(lakeid))
            {
                return(string.Empty);
            }

            AppVars.AutoFishMassa = HelperStrings.SubString(html, "<b>Масса Вашего инвентаря: ", "</b>");
            if (string.IsNullOrEmpty(AppVars.AutoFishMassa))
            {
                return(string.Empty);
            }

            var primid = string.Empty;
            var l1     = new List <string>();

            if ((AppVars.Profile.FishEnabledPrims & Prims.Bread) != 0)
            {
                l1.Add("Хлеб");
            }

            if ((AppVars.Profile.FishEnabledPrims & Prims.Worm) != 0)
            {
                l1.Add("Червяк");
            }

            if ((AppVars.Profile.FishEnabledPrims & Prims.BigWorm) != 0)
            {
                l1.Add("Крупный червяк");
            }

            if ((AppVars.Profile.FishEnabledPrims & Prims.Stink) != 0)
            {
                l1.Add("Опарыш");
            }

            if ((AppVars.Profile.FishEnabledPrims & Prims.Fly) != 0)
            {
                l1.Add("Мотыль");
            }

            if ((AppVars.Profile.FishEnabledPrims & Prims.Light) != 0)
            {
                l1.Add("Блесна");
            }

            if ((AppVars.Profile.FishEnabledPrims & Prims.Donka) != 0)
            {
                l1.Add("Донка");
            }

            if ((AppVars.Profile.FishEnabledPrims & Prims.Morm) != 0)
            {
                l1.Add("Мормышка");
            }

            if ((AppVars.Profile.FishEnabledPrims & Prims.HiFlight) != 0)
            {
                l1.Add("Заговоренная блесна");
            }

            var l2 = new List <string>();

            while (l1.Count > 0)
            {
                var n = Dice.Make(l1.Count);
                l2.Add(l1[n]);
                l1.RemoveAt(n);
            }

            while (l2.Count > 0)
            {
                var pr = string.Empty;
                switch (l2[0])
                {
                case "Хлеб":
                    pr     = "38";
                    primid = "38";
                    break;

                case "Червяк":
                    pr     = "39";
                    primid = "39";
                    break;

                case "Крупный червяк":
                    pr     = "40";
                    primid = "40";
                    break;

                case "Опарыш":
                    pr     = "41";
                    primid = "41";
                    break;

                case "Мотыль":
                    pr     = "42";
                    primid = "42";
                    break;

                case "Блесна":
                    pr     = "43";
                    primid = "43";
                    break;

                case "Донка":
                    pr     = "44";
                    primid = "44";
                    break;

                case "Мормышка":
                    pr     = "45";
                    primid = "45";
                    break;

                case "Заговоренная блесна":
                    pr     = "46";
                    primid = "46";
                    break;
                }

                var temp =
                    "<input type=radio name=primid value=" +
                    primid +
                    "></td><td bgcolor=#FFFFFF><img src=http://image.neverlands.ru/tools/" +
                    pr +
                    ".gif width=60 height=60></td><td bgcolor=#FFFFFF align=center class=nickname><b>" +
                    l2[0] +
                    "</b></td><td bgcolor=#FFFFFF align=center class=nickname><b>";
                var pos = html.IndexOf(temp, StringComparison.OrdinalIgnoreCase);
                if (pos != -1)
                {
                    AppVars.AutoFishLikeId  = primid;
                    AppVars.AutoFishLikeVal = HelperStrings.SubString(html, temp, "</b>");
                    if (pos != -1)
                    {
                        html = html.Insert(pos + 18, "checked ");
                    }

                    break;
                }

                primid = string.Empty;
                l2.RemoveAt(0);
            }

            if (string.IsNullOrEmpty(primid))
            {
                try
                {
                    if (AppVars.MainForm != null)
                    {
                        AppVars.MainForm.BeginInvoke(
                            new UpdateFishOffDelegate(AppVars.MainForm.UpdateFishOff),
                            new object[] { });
                    }
                }
                catch (InvalidOperationException)
                {
                }

                return(string.Empty);
            }

            /*
             * Без капчи
             *  /main.php?get_id=55&lakeid=2&act=4&primid=40&vcode=26ed9c9afae6128894a60e1b8275ebf4
             *
             *  /main.php?get_id=55&lakeid=1&act=4&primid=39&code=57397&vcode=e026c7b0ccf87e33cff2b6907f22679b
             */
            AppVars.FightLink =
                "http://www.neverlands.ru/main.php?get_id=" +
                getid +
                "&lakeid=" +
                lakeid +
                "&act=" +
                act +
                "&primid=" +
                primid +
                (string.IsNullOrEmpty(AppVars.CodeAddress) ? string.Empty : "&code=????") +
                "&vcode=" +
                vcode;

            if (!string.IsNullOrEmpty(AppVars.CodeAddress))
            {
                if (!AppVars.Profile.DoGuamod)
                {
                    if (AppVars.MainForm != null && AppVars.MainForm.TrayIsDigitsWaitTooLong())
                    {
                        try
                        {
                            if (AppVars.MainForm != null)
                            {
                                AppVars.MainForm.BeginInvoke(
                                    new UpdateGuamodTurnOnDelegate(AppVars.MainForm.UpdateGuamodTurnOn),
                                    new object[] { });
                            }
                        }
                        catch (InvalidOperationException)
                        {
                        }
                    }
                    else
                    {
                        EventSounds.PlayDigits();
                        try
                        {
                            if (AppVars.MainForm != null)
                            {
                                AppVars.MainForm.BeginInvoke(
                                    new UpdateTrayFlashDelegate(AppVars.MainForm.UpdateTrayFlash),
                                    new object[] { "Ввод цифр" });
                            }
                        }
                        catch (InvalidOperationException)
                        {
                        }
                    }

                    try
                    {
                        if (AppVars.MainForm != null)
                        {
                            AppVars.MainForm.BeginInvoke(
                                new UpdateTrayFlashDelegate(AppVars.MainForm.UpdateTrayFlash),
                                new object[] { "Ввод цифр" });
                        }
                    }
                    catch (InvalidOperationException)
                    {
                    }
                }
            }

            return(html);
        }