Пример #1
0
        public static void SearchForActionTarget(AudioEventAction action)
        {
            var audioAction = action as InEventAudioAction;

            if (audioAction != null && audioAction.Node != null)
            {
                InAudioWindow.Launch().Find(audioAction.Node);
            }
            var musicControl = action as InEventMusicControl;

            if (musicControl != null && musicControl.Target != null)
            {
                SearchFor(musicControl.MusicGroup);
            }
            var musicFade = action as InEventMusicFade;

            if (musicFade != null && musicFade.Target != null)
            {
                SearchFor(musicFade.To);
            }
            var mixerValue = action as InEventMixerValueAction;

            if (mixerValue != null && mixerValue.Target != null)
            {
                SearchFor(mixerValue.Mixer);
            }

            var soloMuteValue = action as InEventSoloMuteMusic;

            if (soloMuteValue != null && soloMuteValue.Target != null)
            {
                SearchFor(soloMuteValue.MusicGroup);
            }
        }
Пример #2
0
    private static void DrawSelected(AudioEventAction eventAction)
    {
        if (eventAction != null)
        {
            UndoCheck.Instance.CheckUndo(eventAction);
            //UndoCheck.Instance.CheckUndo(eventAction, "Audio Event Action Change");
            Rect thisArea = EditorGUILayout.BeginVertical(GUILayout.Height(100));
            EditorGUILayout.LabelField("");
            var buttonArea = thisArea;
            buttonArea.height = 16;

            GUI.skin.label.alignment = TextAnchor.UpperLeft;
            eventAction.Delay        = Mathf.Max(EditorGUI.FloatField(buttonArea, "Seconds Delay", eventAction.Delay), 0);

            buttonArea.y += 33;
            var busAction = eventAction as EventBusAction;
            if (busAction != null)
            {
                if (busAction.VolumeMode == EventBusAction.VolumeSetMode.Relative)
                {
                    busAction.Volume = EditorGUI.Slider(buttonArea, "Relative Volume", busAction.Volume, -1.0f, 1.0f);
                }
                else
                {
                    busAction.Volume = EditorGUI.Slider(buttonArea, "Volume", busAction.Volume, 0.0f, 1.0f);
                }

                buttonArea.y        += 25;
                busAction.VolumeMode = (EventBusAction.VolumeSetMode)EditorGUI.EnumPopup(buttonArea, "Volume Mode", busAction.VolumeMode);
            }
            EditorGUILayout.EndVertical();
            UndoCheck.Instance.CheckDirty(eventAction);
        }
    }
Пример #3
0
        public static void SearchFor(AudioEventAction action)
        {
            var audioAction = action as InEventAudioAction;

            if (audioAction != null && audioAction.Node != null)
            {
                EditorWindow.GetWindow <InAudioWindow>().Find(audioAction.Node);
            }
            var busAction = action as InEventBusAction;

            if (busAction != null && busAction.Bus != null)
            {
                EditorWindow.GetWindow <AuxWindow>().FindBus(busAction.Bus);
            }
            var busMuteAction = action as InEventBusMuteAction;

            if (busMuteAction != null && busMuteAction.Bus != null)
            {
                EditorWindow.GetWindow <AuxWindow>().FindBus(busMuteAction.Bus);
            }
            var bankAction = action as InEventBankLoadingAction;

            if (bankAction != null && bankAction.BankLink != null)
            {
                EditorWindow.GetWindow <AuxWindow>().FindBank(bankAction.BankLink);
            }
        }
Пример #4
0
 public static void Subscribe(AudioEventAction eventAction)
 {
     if (hasInstance)
     {
         Instance.OnAudioEvent += eventAction;
     }
 }
Пример #5
0
    public static bool Draw(AudioEvent audioevent)
    {
        UndoCheck.Instance.CheckUndo(audioevent);
        audioevent.Name = EditorGUILayout.TextField("Name", audioevent.Name);

        bool repaint = false;

        UndoCheck.Instance.CheckDirty(audioevent);
        if (audioevent.Type == EventNodeType.Event)
        {
            EditorGUILayout.IntField("ID", audioevent.GUID);

            EditorGUILayout.Separator();
            //
            UndoCheck.Instance.CheckUndo(audioevent);
            audioevent.Delay = Mathf.Max(EditorGUILayout.FloatField("Delay", audioevent.Delay), 0);
            UndoCheck.Instance.CheckDirty(audioevent);

            Rect entireArea = EditorGUILayout.BeginVertical();

            NewEventArea(audioevent);
            GUILayoutUtility.GetLastRect();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, true);
            repaint   = DrawContent(audioevent, entireArea);
            EditorGUILayout.EndScrollView();

            DrawSelected(drawnAudioEventAction);

            EditorGUILayout.EndVertical();
        }


        if (audioevent != lastEvent)
        {
            lastEvent = audioevent;
            if (audioevent.ActionList.Count > 0)
            {
                audioEventAction = audioevent.ActionList[0];
            }
            else
            {
                audioEventAction = null;
            }
            drawArea         = new Rect();
            audioEventAction = null;
            scrollPos        = new Vector2();
            repaint          = true;
        }

        if (drawnAudioEventAction != audioEventAction)
        {
            repaint = true;
            drawnAudioEventAction = audioEventAction;
        }

        return(repaint);
    }
        public static AudioEvent DeleteActionAtIndex(AudioEvent audioevent, int index)
        {
            AudioEventAction eventAction = audioevent.ActionList.TryGet(index);

            if (eventAction != null)
            {
                audioevent.ActionList.FindSwapRemove(eventAction);
                Object.DestroyImmediate(eventAction, true);
            }

            return(audioevent);
        }
Пример #7
0
        private static void ShowCreationContext(InAudioEventNode audioevent)
        {
            var menu = new GenericMenu();

            List <EventActionExtension.ActionMeta> actionList = EventActionExtension.GetList();

            foreach (EventActionExtension.ActionMeta currentType in actionList)
            {
                Type newType  = AudioEventAction.ActionEnumToType(currentType.ActionType);
                var  enumType = currentType.ActionType;
                menu.AddItem(new GUIContent(currentType.Name), false, f =>
                             AudioEventWorker.AddEventAction(audioevent, newType, enumType), currentType);
            }
            menu.ShowAsContext();
        }
Пример #8
0
    private static void ShowChangeContext(AudioEvent audioEvent, AudioEventAction action)
    {
        var menu = new GenericMenu();

        foreach (EventActionTypes currentType in EnumUtil.GetValues <EventActionTypes>())
        {
            var enumType = currentType;
            menu.AddItem(
                new GUIContent(currentType.FormatedName()),
                false,
                f => ChangeAction(audioEvent, action, enumType),
                currentType
                );
        }
        menu.ShowAsContext();
    }
Пример #9
0
        private static void HandleDragging(AudioEventAction currentAction, Rect dragArea)
        {
            if (currentAction != null)
            {
                if (currentAction is InEventAudioAction)
                {
                    InAudioNode dragged = OnDragging.DraggingObject <InAudioNode>(dragArea, node => node.IsPlayable);
                    if (dragged != null)
                    {
                        InUndoHelper.RecordObject(currentAction, "Change Action Type");
                        currentAction.Target = dragged;
                    }
                }
                else if (currentAction is InEventBankLoadingAction)
                {
                    InAudioBankLink dragged = OnDragging.DraggingObject <InAudioBankLink>(dragArea,
                                                                                          bank => bank._type == AudioBankTypes.Bank);

                    if (dragged != null)
                    {
                        InUndoHelper.RecordObject(currentAction, "Change Action Type");
                        currentAction.Target = dragged;
                    }
                }
                else if (currentAction is InEventMixerValueAction)
                {
                    AudioMixer dragged = OnDragging.DraggingObject <AudioMixer>(dragArea);
                    if (dragged != null)
                    {
                        InUndoHelper.RecordObject(currentAction, "Change Action Type");
                        currentAction.Target = dragged;
                    }
                }
                else if (currentAction is InEventMusicControl || currentAction is InEventMusicFade || currentAction is InEventSoloMuteMusic)
                {
                    InMusicGroup dragged = OnDragging.DraggingObject <InMusicGroup>(dragArea);
                    if (dragged != null)
                    {
                        InUndoHelper.RecordObject(currentAction, "Change Action Type");
                        currentAction.Target = dragged;
                    }
                }
            }
        }
Пример #10
0
        private static void ShowChangeContext(InAudioEventNode audioEvent, AudioEventAction action)
        {
            var menu = new GenericMenu();

            List <EventActionExtension.ActionMeta> actionList = EventActionExtension.GetList();

            foreach (EventActionExtension.ActionMeta currentType in actionList)
            {
                var enumType = currentType.ActionType;
                menu.AddItem(
                    new GUIContent(currentType.Name),
                    false,
                    f => ChangeAction(audioEvent, action, enumType),
                    currentType.ActionType
                    );
            }

            menu.ShowAsContext();
        }
Пример #11
0
 private static void ChangeAction(AudioEvent audioEvent, AudioEventAction action, EventActionTypes newEnumType)
 {
     for (int i = 0; i < audioEvent.ActionList.Count; ++i)
     {
         if (audioEvent.ActionList[i] == action)
         {
             Type oldType = AudioEventWorker.ActionEnumToType(action.EventActionType);
             Type newType = AudioEventWorker.ActionEnumToType(newEnumType);
             if (oldType != newType)
             {
                 AudioEventWorker.ReplaceActionDestructiveAt(audioEvent, newEnumType, i);
             }
             else
             {
                 action.EventActionType = newEnumType;
             }
             break;
         }
     }
 }
        public static void ReplaceActionDestructiveAt(InAudioEventNode audioEvent, EventActionTypes enumType, int toRemoveAndInsertAt)
        {
            //A reel mess this function.
            //It adds a new component of the specied type, replaces the current at the toRemoveAndInsertAt index, and then deletes the old one
            float  delay         = audioEvent._actionList[toRemoveAndInsertAt].Delay;
            Object target        = audioEvent._actionList[toRemoveAndInsertAt].Target;
            var    newActionType = AudioEventAction.ActionEnumToType(enumType);

            InUndoHelper.Destroy(audioEvent._actionList[toRemoveAndInsertAt]);
            //UndoHelper.RecordObject(audioEvent, "Event Action Creation");

            audioEvent._actionList.RemoveAt(toRemoveAndInsertAt);
            var added = AddEventAction(audioEvent, newActionType, enumType);

            added.Delay  = delay;
            added.Target = target; //Attempt to set the new value, will only work if it is the same type

            audioEvent._actionList.Insert(toRemoveAndInsertAt, added);
            audioEvent._actionList.RemoveLast();
        }
Пример #13
0
        private static void ChangeAction(InAudioEventNode audioEvent, AudioEventAction action, EventActionTypes newEnumType)
        {
            for (int i = 0; i < audioEvent._actionList.Count; ++i)
            {
                if (audioEvent._actionList[i] == action)
                {
                    Type oldType = AudioEventAction.ActionEnumToType(action._eventActionType);
                    Type newType = AudioEventAction.ActionEnumToType(newEnumType);


                    if (oldType != newType)
                    {
                        InUndoHelper.DoInGroup(() => AudioEventWorker.ReplaceActionDestructiveAt(audioEvent, newEnumType, i));
                    }
                    else
                    {
                        InUndoHelper.RecordObject(action, "Change Event Action Type");
                        action._eventActionType = newEnumType;
                    }

                    break;
                }
            }
        }
Пример #14
0
 private static void ClickedInArea(int i)
 {
     audioEventAction = lastEvent._actionList[i];
 }
Пример #15
0
 public void MissingActionTarget(GameObject controllingObject, AudioEventAction eventData)
 {
     Debug.LogWarning("InAudio: Could not run action of type " + eventData._eventActionType + " on object " + controllingObject.name + "\nas the actions target is a null reference");
 }
Пример #16
0
    private IEnumerator PostDelayedActions(GameObject controllingObject, AudioEventAction eventData, GameObject attachedToOther)
    {
        yield return(new WaitForSeconds(eventData.Delay));

        HandleEventAction(controllingObject, eventData, attachedToOther);
    }
Пример #17
0
    /*Internal systems*/
    #region Internal system

    private void HandleEventAction(GameObject controllingObject, AudioEventAction eventData, GameObject attachedTo, Vector3 playAt = new Vector3())
    {
        InAudioNode audioNode; //Because we can't create variables in the scope of the switch with the same name
        InEventBankLoadingAction bankLoadingData;

        if (eventData.Target == null && eventData.EventActionType != EventActionTypes.StopAll)
        {
            InDebug.MissingActionTarget(controllingObject, eventData);
            return;
        }

        switch (eventData.EventActionType)
        {
        case EventActionTypes.Play:
            var audioPlayData = ((InEventAudioAction)eventData);
            audioNode = audioPlayData.Node;
            if (audioNode != null)
            {
                if (attachedTo != null)
                {
                    _inAudioEventWorker.PlayAttachedTo(controllingObject, audioNode, attachedTo, audioPlayData.Fadetime, audioPlayData.TweenType);
                }
                else
                {
                    _inAudioEventWorker.PlayAtPosition(controllingObject, audioNode, playAt, audioPlayData.Fadetime, audioPlayData.TweenType);
                }
            }
            break;

        case EventActionTypes.Stop:
            var data = ((InEventAudioAction)eventData);
            audioNode = data.Node;
            _inAudioEventWorker.StopByNode(controllingObject, audioNode, data.Fadetime, data.TweenType);
            break;

        case EventActionTypes.StopAll:
            var stopAlLData = ((InEventAudioAction)eventData);
            _inAudioEventWorker.StopAll(controllingObject, stopAlLData.Fadetime, stopAlLData.TweenType);
            break;

        case EventActionTypes.Break:
            audioNode = ((InEventAudioAction)eventData).Node;
            _inAudioEventWorker.Break(controllingObject, audioNode);
            break;

        case EventActionTypes.SetBusVolume:
            var busData = eventData as InEventBusAction;
            if (busData != null && busData.Bus != null)
            {
                AudioBusVolumeHelper.SetTargetVolume(busData.Bus, busData.Volume, busData.VolumeMode, busData.Duration, busData.FadeCurve);
            }
            break;

        case EventActionTypes.BankLoading:
            bankLoadingData = eventData as InEventBankLoadingAction;
            if (bankLoadingData != null)
            {
                if (bankLoadingData.LoadingAction == BankHookActionType.Load)
                {
                    BankLoader.Load(bankLoadingData.BankLink);
                }
                else
                {
                    BankLoader.Unload(bankLoadingData.BankLink);
                }
            }
            break;

        case EventActionTypes.StopAllInBus:
            busData = eventData as InEventBusAction;
            if (busData != null && busData.Bus != null)
            {
                StopAllNodeInBus(busData.Bus);
            }
            break;

        case EventActionTypes.SetBusMute:
            var busMuteData = eventData as InEventBusMuteAction;
            if (busMuteData != null && busMuteData.Bus != null)
            {
                AudioBusVolumeHelper.MuteAction(busMuteData.Bus, busMuteData.Action);
            }
            break;

        default:
            InDebug.UnusedActionType(gameObject, eventData);
            break;
        }
    }
Пример #18
0
    private IEnumerator PostDelayedActions(GameObject controllingObject, AudioEventAction eventData, Vector3 postAt)
    {
        yield return(new WaitForSeconds(eventData.Delay));

        HandleEventAction(controllingObject, eventData, null, postAt);
    }
Пример #19
0
        private static void DrawSelected(AudioEventAction eventAction)
        {
            if (eventAction != null)
            {
                Rect thisArea = EditorGUILayout.BeginVertical(GUILayout.Height(120));
                EditorGUILayout.LabelField("");
                var buttonArea = thisArea;
                buttonArea.height = 16;

                GUI.skin.label.alignment = TextAnchor.UpperLeft;

                InUndoHelper.GUIUndo(eventAction, "Event Action Delay", ref eventAction.Delay, () =>
                                     Mathf.Max(EditorGUI.FloatField(buttonArea, "Seconds Delay", eventAction.Delay), 0));

                buttonArea.y += 33;

                var bankLoadingAction   = eventAction as InEventBankLoadingAction;
                var audioAction         = eventAction as InEventAudioAction;
                var snapshotAction      = eventAction as InEventSnapshotAction;
                var mixerAction         = eventAction as InEventMixerValueAction;
                var musicControlAction  = eventAction as InEventMusicControl;
                var musicFadeAction     = eventAction as InEventMusicFade;
                var musicSoloMuteAction = eventAction as InEventSoloMuteMusic;

                if (audioAction != null)
                {
                    if (audioAction._eventActionType == EventActionTypes.Play || audioAction._eventActionType == EventActionTypes.Stop || audioAction._eventActionType == EventActionTypes.StopAll)
                    {
                        InUndoHelper.GUIUndo(audioAction, "Fade Time", ref audioAction.Fadetime,
                                             () => Mathf.Max(0, EditorGUILayout.FloatField("Fade Time", audioAction.Fadetime)));
                        InUndoHelper.GUIUndo(audioAction, "Fade Type", ref audioAction.TweenType,
                                             () => (LeanTweenType)EditorGUILayout.EnumPopup("Fade Type", audioAction.TweenType));
                        if (audioAction.TweenType == LeanTweenType.animationCurve)
                        {
                            EditorGUILayout.HelpBox("Animation curve type is not supported", MessageType.Warning);
                        }
                    }
                }
                else if (bankLoadingAction != null)
                {
                    //todo
                }
                else if (snapshotAction != null)
                {
                    InUndoHelper.GUIUndo(snapshotAction, "Snapshot Transition Action", ref snapshotAction.Snapshot, () =>
                                         (AudioMixerSnapshot)EditorGUILayout.ObjectField("Transition Action", snapshotAction.Snapshot, typeof(AudioMixerSnapshot), false));
                    InUndoHelper.GUIUndo(snapshotAction, "Snapshot Transition Time", ref snapshotAction.TransitionTime, () =>
                                         EditorGUILayout.FloatField("Transition Time", snapshotAction.TransitionTime));
                }
                else if (mixerAction != null)
                {
                    InUndoHelper.GUIUndo(mixerAction, "Mixer Value", ref mixerAction.Mixer, () =>
                                         (AudioMixer)EditorGUILayout.ObjectField("Audio Mixer", mixerAction.Mixer, typeof(AudioMixer), false));
                    InUndoHelper.GUIUndo(mixerAction, "Parameter", ref mixerAction.Parameter, () =>
                                         EditorGUILayout.TextField("Parameter", mixerAction.Parameter));
                    InUndoHelper.GUIUndo(mixerAction, "Value", ref mixerAction.Value, () =>
                                         EditorGUILayout.FloatField("Value", mixerAction.Value));
                    EditorGUILayout.Separator();
                    InUndoHelper.GUIUndo(mixerAction, "Transition Time", ref mixerAction.TransitionTime, () =>
                                         Mathf.Max(0, EditorGUILayout.FloatField("Transition Time", mixerAction.TransitionTime)));
                    InUndoHelper.GUIUndo(mixerAction, "Transition Type", ref mixerAction.TransitionType, () =>
                                         (LeanTweenType)EditorGUILayout.EnumPopup("Transition Type", mixerAction.TransitionType));
                    if (mixerAction.TransitionType == LeanTweenType.animationCurve)
                    {
                        EditorGUILayout.HelpBox("Animation curve type is not supported", MessageType.Warning);
                    }
                }
                else if (musicControlAction != null)
                {
                    InUndoHelper.GUIUndo(musicControlAction, "Fade Action", ref musicControlAction.Fade, () =>
                                         EditorGUILayout.Toggle("Fade Action", musicControlAction.Fade));

                    if (musicControlAction.Fade)
                    {
                        InUndoHelper.GUIUndo(musicControlAction, "Transition Time", ref musicControlAction.Duration, () =>
                                             Mathf.Max(0, EditorGUILayout.FloatField("Transition Time", musicControlAction.Duration)));

                        InUndoHelper.GUIUndo(musicControlAction, "Transition Type", ref musicControlAction.TweenType, () =>
                                             (LeanTweenType)EditorGUILayout.EnumPopup("Transition Type", musicControlAction.TweenType));
                    }


                    InUndoHelper.GUIUndo(musicControlAction, "Set Volume Target", ref musicControlAction.ChangeVolume,
                                         () =>
                                         EditorGUILayout.Toggle("Set Volume Target", musicControlAction.ChangeVolume));
                    if (musicControlAction.ChangeVolume)
                    {
                        InUndoHelper.GUIUndo(musicControlAction, "Volume Target", ref musicControlAction.Duration,
                                             () => Mathf.Clamp01(EditorGUILayout.Slider("Volume Target", musicControlAction.Duration, 0, 1)));
                    }
                }
                else if (musicFadeAction != null)
                {
                    if (musicFadeAction._eventActionType == EventActionTypes.CrossfadeMusic)
                    {
                        InUndoHelper.GUIUndo(musicFadeAction, "Fade Target", ref musicFadeAction.From, () => EditorGUILayout.ObjectField("From Target", musicFadeAction.To, typeof(InEventMusicFade), false) as InMusicGroup);
                        InUndoHelper.GUIUndo(musicFadeAction, "Fade Target", ref musicFadeAction.To, () => EditorGUILayout.ObjectField("To Target", musicFadeAction.To, typeof(InEventMusicFade), false) as InMusicGroup);
                    }

                    if (musicFadeAction._eventActionType == EventActionTypes.FadeMusic)
                    {
                        InUndoHelper.GUIUndo(musicFadeAction, "Volume Target", ref musicFadeAction.ToVolumeTarget, () =>
                                             EditorGUILayout.Slider("Volume Target", musicFadeAction.ToVolumeTarget, 0f, 1f));
                    }

                    InUndoHelper.GUIUndo(musicFadeAction, "Transition Time", ref musicFadeAction.Duration, () =>
                                         Mathf.Max(0, EditorGUILayout.FloatField("Transition Time", musicFadeAction.Duration)));

                    InUndoHelper.GUIUndo(musicFadeAction, "Transition Type", ref musicFadeAction.TweenType, () =>
                                         (LeanTweenType)EditorGUILayout.EnumPopup("Transition Type", musicFadeAction.TweenType));

                    if (musicFadeAction.TweenType == LeanTweenType.animationCurve)
                    {
                        EditorGUILayout.HelpBox("Animation curve type is not supported", MessageType.Warning);
                    }

                    if (musicFadeAction._eventActionType == EventActionTypes.FadeMusic)
                    {
                        InUndoHelper.GUIUndo(musicFadeAction, "Do At End", ref musicFadeAction.DoAtEndTo, () =>
                                             (MusicState)EditorGUILayout.EnumPopup("Do At End", musicFadeAction.DoAtEndTo));
                        if (musicFadeAction.DoAtEndTo == MusicState.Playing)
                        {
                            EditorGUILayout.HelpBox("\"Playing\" does the same as \"Nothing\", it does not start playing", MessageType.Info);
                        }
                    }
                }
                else if (musicSoloMuteAction != null)
                {
                    InUndoHelper.GUIUndo(musicSoloMuteAction, "Set Solo", ref musicSoloMuteAction.SetSolo, () =>
                                         EditorGUILayout.Toggle("Set Solo", musicSoloMuteAction.SetSolo));
                    if (musicSoloMuteAction.SetSolo)
                    {
                        InUndoHelper.GUIUndo(musicSoloMuteAction, "Solo Target", ref musicSoloMuteAction.SoloTarget, () =>
                                             EditorGUILayout.Toggle("Solo Target", musicSoloMuteAction.SoloTarget));
                    }
                    EditorGUILayout.Separator();
                    InUndoHelper.GUIUndo(musicSoloMuteAction, "Set Mute", ref musicSoloMuteAction.SetMute, () =>
                                         EditorGUILayout.Toggle("Set Mute", musicSoloMuteAction.SetMute));
                    if (musicSoloMuteAction.SetMute)
                    {
                        InUndoHelper.GUIUndo(musicSoloMuteAction, "Solo Mute", ref musicSoloMuteAction.MuteTarget, () =>
                                             EditorGUILayout.Toggle("Solo Mute", musicSoloMuteAction.MuteTarget));
                    }
                }
                EditorGUILayout.EndVertical();
            }
        }
Пример #20
0
    private static void DrawItem(Rect position, int i)
    {
        var item = lastEvent._actionList[i];
        leftStyle.alignment = TextAnchor.MiddleLeft;
        if(item == audioEventAction)
            DrawBackground(position);

        Rect fullArea = position;
        Rect typePos = position;
        typePos.width = 110;
        if (item != null)
        {
            
            if (GUI.Button(typePos, EventActionExtension.GetList().Find(p => p.Value == (int)item._eventActionType).Name))
            {
                ShowChangeContext(lastEvent, item);
                Event.current.UseEvent();
            }
        }
        else
            GUI.Label(position, "Missing data", leftStyle);


        typePos.x += 130;
        if (item != null && item._eventActionType != EventActionTypes.StopAll && item._eventActionType != EventActionTypes.StopAllMusic)
        {
            Rect area = typePos;
            area.width = position.width - 200;
            GUI.Label(area, item.ObjectName);
        }
        HandleDragging(item, typePos);

        position.x = position.x + position.width - 75;
        position.width = 45;

        if (item != null && item._eventActionType != EventActionTypes.StopAll && item._eventActionType != EventActionTypes.StopAllMusic)
        {
            if (GUI.Button(position, "Find"))
            {
                SearchHelper.SearchForActionTarget(item);
            }
        }

        position.x += 50;
        position.width = 20;

        if (audioEventAction == item)
        {
            DrawBackground(position);
        }

        if (GUI.Button(position, "X"))
        {
            toRemove = item;
        }

        if (Event.current.ClickedWithin(fullArea))
        {
            audioEventAction = item;
            Event.current.UseEvent();
        }
    }
Пример #21
0
    private void HandleEventAction(GameObject controllingObject, AudioEventAction eventData, GameObject attachedTo, Vector3 playAt = new Vector3())
    {
        AudioNode       audioNode; //Because we can't create variables in the scope of the switch with the same name
        EventBankAction bankData;

        switch (eventData.EventActionType)
        {
        case EventActionTypes.Play:
            audioNode = ((EventAudioAction)eventData).Node;
            if (attachedTo != null)
            {
                audioPlayer.Play(controllingObject, audioNode, attachedTo);
            }
            else
            {
                audioPlayer.PlayAtPosition(controllingObject, audioNode, playAt);
            }
            break;

        case EventActionTypes.Stop:
            audioNode = ((EventAudioAction)eventData).Node;
            audioPlayer.StopByNode(controllingObject, audioNode);
            break;

        case EventActionTypes.StopAll:
            audioPlayer.StopAll(controllingObject);
            break;

        case EventActionTypes.Break:
            audioNode = ((EventAudioAction)eventData).Node;
            audioPlayer.Break(controllingObject, audioNode);
            break;

        case EventActionTypes.SetBusVolume:
            var busData = eventData as EventBusAction;
            if (busData != null && busData.Bus != null)
            {
                AudioBusVolumeHelper.SetTargetVolume(busData.Bus, busData.Volume, busData.VolumeMode);
            }
            break;

        case EventActionTypes.LoadBank:
            bankData = eventData as EventBankAction;
            if (bankData != null)
            {
                BankLoader.Load(bankData.BankLink);
            }
            break;

        case EventActionTypes.UnloadBank:
            bankData = eventData as EventBankAction;
            if (bankData != null)
            {
                BankLoader.Unload(bankData.BankLink);
            }
            break;

        case EventActionTypes.StopAllInBus:
            busData = eventData as EventBusAction;
            if (busData != null && busData.Bus != null)
            {
                StopAllNodeInBus(busData.Bus);
            }
            break;
        }
    }
Пример #22
0
 private static void ClickedInArea(int i)
 {
     audioEventAction = lastEvent._actionList[i];
 }
Пример #23
0
    private static bool DrawContent(AudioEvent audioevent, Rect area)
    {
        Rect selectedBackground = drawArea;

        selectedBackground.y += 2;
        DrawBackground(selectedBackground);
        GUI.skin.label.alignment = TextAnchor.MiddleCenter;
        bool repaint = false;

        EditorGUILayout.BeginVertical();
        for (int i = 0; i < audioevent.ActionList.Count; ++i)
        {
            var  currentAction = audioevent.ActionList[i];
            Rect lastArea      = EditorGUILayout.BeginHorizontal(GUILayout.Height(20));

            if (i == 0)
            {
                Rect actionArea = lastArea;
                actionArea.width  = 100;
                actionArea.height = 20;
                actionArea.y     -= 20;

                EditorGUI.LabelField(actionArea, "Action", EditorStyles.boldLabel);
            }

            if (currentAction != null)
            {
                if (GUILayout.Button(
                        Enum.GetName(typeof(EventActionTypes), (int)currentAction.EventActionType)
                        .AddSpacesToSentence(),
                        GUILayout.Width(110)))
                {
                    ShowChangeContext(audioevent, currentAction);
                    Event.current.Use();
                }
            }
            else
            {
                EditorGUILayout.LabelField("Missing");

                GUI.enabled = false;
            }

            EditorGUILayout.BeginVertical(GUILayout.Height(20));
            GUILayout.Label("", GUILayout.Height(0)); //Aligns it to the center by creating a small vertical offset, by setting the height to zero
            if (currentAction != null && currentAction.EventActionType != EventActionTypes.StopAll)
            {
                EditorGUILayout.LabelField(currentAction.ObjectName);
            }
            EditorGUILayout.EndHorizontal();

            Rect dragArea = GUILayoutUtility.GetLastRect();

            if (i == 0)
            {
                Rect actionArea = dragArea;
                actionArea.width  = 100;
                actionArea.height = 20;
                actionArea.y     -= 20;

                EditorGUI.LabelField(actionArea, "Data", EditorStyles.boldLabel);
            }

            if (currentAction is EventAudioAction)
            {
                AudioNode dragged = OnDragging.DraggingObject <AudioNode>(dragArea, node => node.IsPlayable);

                if (dragged != null)
                {
                    (currentAction as EventAudioAction).Node = dragged;
                }
            }
            else if (currentAction is EventBankAction)
            {
                AudioBankLink dragged = OnDragging.DraggingObject <AudioBankLink>(dragArea, bank => bank.Type == AudioBankTypes.Link);
                if (dragged != null)
                {
                    (currentAction as EventBankAction).BankLink = dragged;
                }
            }
            else if (currentAction is EventBusAction)
            {
                AudioBus dragged = OnDragging.DraggingObject <AudioBus>(dragArea, bus => true);
                if (dragged != null)
                {
                    (currentAction as EventBusAction).Bus = dragged;
                }
            }

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            Rect rightArea = EditorGUILayout.BeginHorizontal(GUILayout.Width(area.width - 100));
            rightArea.x    -= 150;
            rightArea.y    += 3;
            rightArea.width = 80;
            //rightARea.height -= 6;
            if (GUI.Button(rightArea, "Find"))
            {
                SearchHelper.SearchFor(currentAction);
            }

            rightArea.x    += 90;
            rightArea.width = 30;
            if (GUI.Button(rightArea, "X"))
            {
                if (audioevent.ActionList[i] != null)
                {
                    AudioEventWorker.DeleteActionAtIndex(audioevent, i);
                }
                else
                {
                    audioevent.ActionList.SwapRemoveAt(i);
                    --i;
                }
            }

            if (Event.current.ClickedWithin(lastArea))
            {
                drawArea         = lastArea;
                audioEventAction = currentAction;
                Event.current.Use();
            }
            //if (audioEventAction == null || ( Event.current.type == EventType.MouseDown && lastArea.Contains(Event.current.mousePosition)))
            //{
            //    drawArea = lastArea;
            //    audioEventAction = currentAction;
            //}
            GUILayout.Label("");
            //EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndHorizontal();

            GUI.enabled = true;
        }
        EditorGUILayout.EndVertical();
        return(repaint);
    }
Пример #24
0
 public void UnusedActionType(GameObject controllingObject, AudioEventAction eventData)
 {
     Debug.LogWarning("InAudio: Could not run action of type " + eventData._eventActionType + " on object " + controllingObject.name + " as the actionis not in use by InAudio yet");
 }
Пример #25
0
 public void MissingActionTarget(GameObject controllingObject, AudioEventAction eventData)
 {
     LogWarning("InAudio: Could not run action of type " + eventData.EventActionType + " on object " + controllingObject.name + "\nas the actions target is a null reference");
 }
Пример #26
0
 public void UnusedActionType(GameObject controllingObject, AudioEventAction eventData)
 {
     LogWarning("InAudio: Could not run action of type " + eventData.EventActionType + " on object " + controllingObject.name + " as the actionis not in use by InAudio yet");
 }
Пример #27
0
    private static void DrawSelected(AudioEventAction eventAction)
    {
        if (eventAction != null)
        {
            Rect thisArea = EditorGUILayout.BeginVertical(GUILayout.Height(120));
            EditorGUILayout.LabelField("");
            var buttonArea = thisArea;
            buttonArea.height = 16;

            GUI.skin.label.alignment = TextAnchor.UpperLeft;

            InUndoHelper.GUIUndo(eventAction, "Event Action Delay", ref eventAction.Delay, () =>
                Mathf.Max(EditorGUI.FloatField(buttonArea, "Seconds Delay", eventAction.Delay), 0));
            
            buttonArea.y += 33;

            var bankLoadingAction = eventAction as InEventBankLoadingAction;
            var audioAction = eventAction as InEventAudioAction;
            var snapshotAction = eventAction as InEventSnapshotAction;
            var mixerAction = eventAction as InEventMixerValueAction;
            var musicControlAction = eventAction as InEventMusicControl;
            var musicFadeAction = eventAction as InEventMusicFade;
            var musicSoloMuteAction = eventAction as InEventSoloMuteMusic;

            if (audioAction != null)
            {
                if (audioAction._eventActionType == EventActionTypes.Play || audioAction._eventActionType == EventActionTypes.Stop || audioAction._eventActionType == EventActionTypes.StopAll)
                {
                    InUndoHelper.GUIUndo(audioAction, "Fade Time", ref audioAction.Fadetime,
                        () => Mathf.Max(0, EditorGUILayout.FloatField("Fade Time", audioAction.Fadetime)));
                    InUndoHelper.GUIUndo(audioAction, "Fade Type", ref audioAction.TweenType,
                        () => (LeanTweenType) EditorGUILayout.EnumPopup("Fade Type", audioAction.TweenType));
                    if (audioAction.TweenType == LeanTweenType.animationCurve)
                    {
                        EditorGUILayout.HelpBox("Animation curve type is not supported", MessageType.Warning);
                    }
                }
            }
            else if (bankLoadingAction != null)
            {
                InUndoHelper.GUIUndo(bankLoadingAction, "Bank Loading Action", ref bankLoadingAction.LoadingAction, () =>
                    (BankHookActionType)EditorGUI.EnumPopup(buttonArea, "Load Action", bankLoadingAction.LoadingAction));
            }
            else if (snapshotAction != null)
            {
                InUndoHelper.GUIUndo(snapshotAction, "Snapshot Transition Action", ref snapshotAction.Snapshot, () =>
                    (AudioMixerSnapshot)EditorGUILayout.ObjectField("Transition Action", snapshotAction.Snapshot, typeof(AudioMixerSnapshot), false));
                InUndoHelper.GUIUndo(snapshotAction, "Snapshot Transition Time", ref snapshotAction.TransitionTime, () => 
                    EditorGUILayout.FloatField("Transition Time", snapshotAction.TransitionTime));
            }
            else if (mixerAction != null)
            {
                InUndoHelper.GUIUndo(mixerAction, "Mixer Value", ref mixerAction.Mixer, () =>
                    (AudioMixer)EditorGUILayout.ObjectField("Audio Mixer", mixerAction.Mixer, typeof(AudioMixer), false));
                InUndoHelper.GUIUndo(mixerAction, "Parameter", ref mixerAction.Parameter, () =>
                    EditorGUILayout.TextField("Parameter", mixerAction.Parameter));
                InUndoHelper.GUIUndo(mixerAction, "Value", ref mixerAction.Value, () =>
                    EditorGUILayout.FloatField("Value", mixerAction.Value));
                EditorGUILayout.Separator();
                InUndoHelper.GUIUndo(mixerAction, "Transition Time", ref mixerAction.TransitionTime, () =>
                    Mathf.Max(0, EditorGUILayout.FloatField("Transition Time", mixerAction.TransitionTime)));
                InUndoHelper.GUIUndo(mixerAction, "Transition Type", ref mixerAction.TransitionType, () =>
                    (LeanTweenType)EditorGUILayout.EnumPopup("Transition Type", mixerAction.TransitionType));
                if (mixerAction.TransitionType == LeanTweenType.animationCurve)
                {
                    EditorGUILayout.HelpBox("Animation curve type is not supported", MessageType.Warning);
                }
            }
            else if (musicControlAction != null)
            {
                InUndoHelper.GUIUndo(musicControlAction, "Fade Action", ref musicControlAction.Fade, () =>
                        EditorGUILayout.Toggle("Fade Action", musicControlAction.Fade));

                if (musicControlAction.Fade)
                {
                    InUndoHelper.GUIUndo(musicControlAction, "Transition Time", ref musicControlAction.Duration, () =>
                        Mathf.Max(0, EditorGUILayout.FloatField("Transition Time", musicControlAction.Duration)));

                    InUndoHelper.GUIUndo(musicControlAction, "Transition Type", ref musicControlAction.TweenType, () =>
                        (LeanTweenType) EditorGUILayout.EnumPopup("Transition Type", musicControlAction.TweenType));

                   
                }

                
                InUndoHelper.GUIUndo(musicControlAction, "Set Volume Target", ref musicControlAction.ChangeVolume,
                    () =>
                        EditorGUILayout.Toggle("Set Volume Target", musicControlAction.ChangeVolume));
                if (musicControlAction.ChangeVolume)
                {
                    InUndoHelper.GUIUndo(musicControlAction, "Volume Target", ref musicControlAction.Duration,
                        () => Mathf.Clamp01(EditorGUILayout.Slider("Volume Target", musicControlAction.Duration, 0, 1)));
                }
                
            }
            else if (musicFadeAction != null)
            {
                if (musicFadeAction._eventActionType == EventActionTypes.CrossfadeMusic)
                {
                    InUndoHelper.GUIUndo(musicFadeAction, "Fade Target", ref musicFadeAction.From, () => EditorGUILayout.ObjectField("From Target", musicFadeAction.To, typeof(InEventMusicFade),false) as InMusicGroup);
                    InUndoHelper.GUIUndo(musicFadeAction, "Fade Target", ref musicFadeAction.To, () => EditorGUILayout.ObjectField("To Target", musicFadeAction.To, typeof(InEventMusicFade), false) as InMusicGroup);    
                }

                if (musicFadeAction._eventActionType == EventActionTypes.FadeMusic)
                {
                    InUndoHelper.GUIUndo(musicFadeAction, "Volume Target", ref musicFadeAction.ToVolumeTarget, () =>
                        EditorGUILayout.Slider("Volume Target", musicFadeAction.ToVolumeTarget, 0f, 1f));
                }

                InUndoHelper.GUIUndo(musicFadeAction, "Transition Time", ref musicFadeAction.Duration, () =>
                    Mathf.Max(0, EditorGUILayout.FloatField("Transition Time", musicFadeAction.Duration)));

                InUndoHelper.GUIUndo(musicFadeAction, "Transition Type", ref musicFadeAction.TweenType, () =>
                    (LeanTweenType)EditorGUILayout.EnumPopup("Transition Type", musicFadeAction.TweenType));
                
                if (musicFadeAction.TweenType == LeanTweenType.animationCurve)
                {
                    EditorGUILayout.HelpBox("Animation curve type is not supported", MessageType.Warning);
                }

                if (musicFadeAction._eventActionType == EventActionTypes.FadeMusic)
                {
                    InUndoHelper.GUIUndo(musicFadeAction, "Do At End", ref musicFadeAction.DoAtEndTo, () =>
                        (MusicState)EditorGUILayout.EnumPopup("Do At End", musicFadeAction.DoAtEndTo));
                    if (musicFadeAction.DoAtEndTo == MusicState.Playing)
                    {
                        EditorGUILayout.HelpBox("\"Playing\" does the same as \"Nothing\", it does not start playing", MessageType.Info );
                    }
                }
                
            }
            else if (musicSoloMuteAction != null)
            {
                InUndoHelper.GUIUndo(musicSoloMuteAction, "Set Solo", ref musicSoloMuteAction.SetSolo, () =>
                        EditorGUILayout.Toggle("Set Solo", musicSoloMuteAction.SetSolo));
                if (musicSoloMuteAction.SetSolo)
                {
                    InUndoHelper.GUIUndo(musicSoloMuteAction, "Solo Target", ref musicSoloMuteAction.SoloTarget, () =>
                        EditorGUILayout.Toggle("Solo Target", musicSoloMuteAction.SoloTarget));
                }
                EditorGUILayout.Separator();
                InUndoHelper.GUIUndo(musicSoloMuteAction, "Set Mute", ref musicSoloMuteAction.SetMute, () =>
                        EditorGUILayout.Toggle("Set Mute", musicSoloMuteAction.SetMute));
                if (musicSoloMuteAction.SetMute)
                {
                    InUndoHelper.GUIUndo(musicSoloMuteAction, "Solo Mute", ref musicSoloMuteAction.MuteTarget, () =>
                        EditorGUILayout.Toggle("Solo Mute", musicSoloMuteAction.MuteTarget));
                }
            }
            EditorGUILayout.EndVertical();
        }
    }
Пример #28
0
    public static bool Draw(InAudioEventNode audioevent)
    {
        if (ListAdapter == null)
        {
            ListAdapter = new EventActionListAdapter();
            ListAdapter.DrawEvent = DrawItem;
            ListAdapter.ClickedInArea = ClickedInArea;
        }

        if (lastEvent != audioevent)
        {
            ListAdapter.Event = audioevent;

            audioEventAction = null;
            if (audioevent._actionList.Count > 0)
            {
                audioEventAction = audioevent._actionList[0];
            }
        }
        EditorGUILayout.BeginVertical();

        lastEvent = audioevent;
        InUndoHelper.GUIUndo(audioevent, "Name Change", ref audioevent.Name, () => 
            EditorGUILayout.TextField("Name", audioevent.Name));
        
        bool repaint = false;
      
        if (audioevent._type == EventNodeType.Event)
        {
            EditorGUIHelper.DrawID(audioevent._guid);

            if (Application.isPlaying)
            {
                eventObjectTarget = EditorGUILayout.ObjectField("Event preview target", eventObjectTarget, typeof(GameObject), true) as GameObject;
                
                if (eventObjectTarget != null )
                {
                    bool prefab = PrefabUtility.GetPrefabParent(eventObjectTarget) == null && PrefabUtility.GetPrefabObject(eventObjectTarget) != null;
                    if (!prefab)
                    {
                        EditorGUILayout.BeginHorizontal();
                        if (GUILayout.Button("Post event"))
                        {
                            InAudio.PostEvent(eventObjectTarget, audioevent);
                        }
                        if (GUILayout.Button("Stop All Sounds/Music in Event"))
                        {
                            InAudio.StopAll(eventObjectTarget);
                            foreach (var eventAction in audioevent._actionList)
                            {
                                var music = eventAction.Target as InMusicGroup;
                                if (music != null)
                                {
                                    InAudio.Music.Stop(music);
                                }
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Cannot post events on Prefab", MessageType.Error);
                    }
                }
                EditorGUILayout.Separator();
            }

            

            InUndoHelper.GUIUndo(audioevent, "Delay", ref audioevent.Delay, () =>
                Mathf.Max(EditorGUILayout.FloatField("Delay", audioevent.Delay), 0));
          
            NewEventArea(audioevent);

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

                repaint = DrawContent();

            EditorGUILayout.EndScrollView();
            DrawSelected(audioEventAction);
        }
        else if (audioevent._type == EventNodeType.Folder)
        {
            if (audioevent.PlacedExternaly)
            {
                EditorGUILayout.Separator();

                GUI.enabled = false;
                EditorGUILayout.ObjectField("Placed on", audioevent.gameObject, typeof(GameObject), false);
                GUI.enabled = true;

                EditorGUILayout.Separator();
            }
        }

        EditorGUILayout.EndVertical(); 

        if (toRemove != null)
        {
            InUndoHelper.DoInGroup(() =>
            {
                //Remove the required piece
                int index = audioevent._actionList.FindIndex(toRemove);
                AudioEventWorker.DeleteActionAtIndex(audioevent, index);
                
            });
            toRemove = null;

        }
        else //Remove all actions that does not excist. 
        {
            audioevent._actionList.RemoveAll(p => p == null);
        }
        return repaint;
    }
Пример #29
0
    private static void ShowChangeContext(InAudioEventNode audioEvent, AudioEventAction action)
    {
        var menu = new GenericMenu();

        List<EventActionExtension.ActionMeta> actionList = EventActionExtension.GetList();
        foreach (EventActionExtension.ActionMeta currentType in actionList)
        {
            var enumType = currentType.ActionType;
            menu.AddItem(
                new GUIContent(currentType.Name),
                false,
                f => ChangeAction(audioEvent, action, enumType),
                currentType.ActionType
                );
        }
        
        menu.ShowAsContext();
    }
Пример #30
0
    private static void HandleDragging(AudioEventAction currentAction, Rect dragArea)
    {
        if (currentAction != null)
        {
            
            if (currentAction is InEventAudioAction)
            {
                InAudioNode dragged = OnDragging.DraggingObject<InAudioNode>(dragArea, node => node.IsPlayable);
                if (dragged != null)
                {
                    InUndoHelper.RecordObject(currentAction, "Change Action Type");
                    currentAction.Target = dragged;
                }
            }
            else if (currentAction is InEventBankLoadingAction)
            {
                InAudioBankLink dragged = OnDragging.DraggingObject<InAudioBankLink>(dragArea,
                    bank => bank._type == AudioBankTypes.Bank);

                if (dragged != null)
                {
                    InUndoHelper.RecordObject(currentAction, "Change Action Type");
                    currentAction.Target = dragged;
                }
            }
            else if(currentAction is InEventMixerValueAction)
            {
                AudioMixer dragged = OnDragging.DraggingObject<AudioMixer>(dragArea);
                if (dragged != null)
                {
                    InUndoHelper.RecordObject(currentAction, "Change Action Type");
                    currentAction.Target = dragged;
                }
            }
            else if (currentAction is InEventMusicControl || currentAction is InEventMusicFade || currentAction is InEventSoloMuteMusic)
            {
                InMusicGroup dragged = OnDragging.DraggingObject<InMusicGroup>(dragArea);
                if (dragged != null)
                {
                    InUndoHelper.RecordObject(currentAction, "Change Action Type");
                    currentAction.Target = dragged;
                }
            }
        }
    }
Пример #31
0
        public static bool Draw(InAudioEventNode audioevent)
        {
            if (ListAdapter == null)
            {
                ListAdapter               = new EventActionListAdapter();
                ListAdapter.DrawEvent     = DrawItem;
                ListAdapter.ClickedInArea = ClickedInArea;
            }

            if (lastEvent != audioevent)
            {
                ListAdapter.Event = audioevent;

                audioEventAction = null;
                if (audioevent._actionList.Count > 0)
                {
                    audioEventAction = audioevent._actionList[0];
                }
            }
            EditorGUILayout.BeginVertical();

            lastEvent = audioevent;
            InUndoHelper.GUIUndo(audioevent, "Name Change", ref audioevent.Name, () =>
                                 EditorGUILayout.TextField("Name", audioevent.Name));

            bool repaint = false;

            if (audioevent._type == EventNodeType.Event)
            {
                EditorGUIHelper.DrawID(audioevent._guid);

                if (Application.isPlaying)
                {
                    eventObjectTarget = EditorGUILayout.ObjectField("Event preview target", eventObjectTarget, typeof(GameObject), true) as GameObject;

                    if (eventObjectTarget != null)
                    {
                        bool prefab = PrefabUtility.GetPrefabParent(eventObjectTarget) == null && PrefabUtility.GetPrefabObject(eventObjectTarget) != null;
                        if (!prefab)
                        {
                            EditorGUILayout.BeginHorizontal();
                            if (GUILayout.Button("Post event"))
                            {
                                InAudio.PostEvent(eventObjectTarget, audioevent);
                            }
                            if (GUILayout.Button("Stop All Sounds/Music in Event"))
                            {
                                InAudio.StopAll(eventObjectTarget);
                                foreach (var eventAction in audioevent._actionList)
                                {
                                    var music = eventAction.Target as InMusicGroup;
                                    if (music != null)
                                    {
                                        InAudio.Music.Stop(music);
                                    }
                                }
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("Cannot post events on Prefab", MessageType.Error);
                        }
                    }
                    EditorGUILayout.Separator();
                }



                InUndoHelper.GUIUndo(audioevent, "Delay", ref audioevent.Delay, () =>
                                     Mathf.Max(EditorGUILayout.FloatField("Delay", audioevent.Delay), 0));

                NewEventArea(audioevent);

                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

                repaint = DrawContent();

                EditorGUILayout.EndScrollView();
                DrawSelected(audioEventAction);
            }
            else if (audioevent._type == EventNodeType.Folder)
            {
                if (audioevent.PlacedExternaly)
                {
                    EditorGUILayout.Separator();

                    GUI.enabled = false;
                    EditorGUILayout.ObjectField("Placed on", audioevent.gameObject, typeof(GameObject), false);
                    GUI.enabled = true;

                    EditorGUILayout.Separator();
                }
            }

            EditorGUILayout.EndVertical();

            if (toRemove != null)
            {
                InUndoHelper.DoInGroup(() =>
                {
                    //Remove the required piece
                    int index = audioevent._actionList.FindIndex(toRemove);
                    AudioEventWorker.DeleteActionAtIndex(audioevent, index);
                });
                toRemove = null;
            }
            else //Remove all actions that does not excist.
            {
                audioevent._actionList.RemoveAll(p => p == null);
            }
            return(repaint);
        }
Пример #32
0
    private static void ChangeAction(InAudioEventNode audioEvent, AudioEventAction action, EventActionTypes newEnumType)
    {
        for (int i = 0; i < audioEvent._actionList.Count; ++i)
        {
            if (audioEvent._actionList[i] == action)
            {
                Type oldType = AudioEventAction.ActionEnumToType(action._eventActionType);
                Type newType = AudioEventAction.ActionEnumToType(newEnumType);


                if (oldType != newType)
                {
                    InUndoHelper.DoInGroup(() => AudioEventWorker.ReplaceActionDestructiveAt(audioEvent, newEnumType, i));
                }
                else
                {
                    InUndoHelper.RecordObject(action, "Change Event Action Type");
                    action._eventActionType = newEnumType;
                }    
                
                break;
            }
        }
    }
Пример #33
0
        private static void DrawItem(Rect position, int i)
        {
            var item = lastEvent._actionList[i];

            leftStyle.alignment = TextAnchor.MiddleLeft;
            if (item == audioEventAction)
            {
                DrawBackground(position);
            }

            Rect fullArea = position;
            Rect typePos  = position;

            typePos.width = 110;
            if (item != null)
            {
                if (GUI.Button(typePos, EventActionExtension.GetList().Find(p => p.Value == (int)item._eventActionType).Name))
                {
                    ShowChangeContext(lastEvent, item);
                    Event.current.UseEvent();
                }
            }
            else
            {
                GUI.Label(position, "Missing data", leftStyle);
            }


            typePos.x += 130;
            if (item != null && item._eventActionType != EventActionTypes.StopAll && item._eventActionType != EventActionTypes.StopAllMusic)
            {
                Rect area = typePos;
                area.width = position.width - 200;
                GUI.Label(area, item.ObjectName);
            }
            HandleDragging(item, typePos);

            position.x     = position.x + position.width - 75;
            position.width = 45;

            if (item != null && item._eventActionType != EventActionTypes.StopAll && item._eventActionType != EventActionTypes.StopAllMusic)
            {
                if (GUI.Button(position, "Find"))
                {
                    SearchHelper.SearchForActionTarget(item);
                }
            }

            position.x    += 50;
            position.width = 20;

            if (audioEventAction == item)
            {
                DrawBackground(position);
            }

            if (GUI.Button(position, "X"))
            {
                toRemove = item;
            }

            if (Event.current.ClickedWithin(fullArea))
            {
                audioEventAction = item;
                Event.current.UseEvent();
            }
        }