public override void OnChildInspectorGUI()
    {
        m_UnityEventHandlerInspector.OnGUI();

        DisplayActionOnEvent();
        DisplayCallbackInformation();

        UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);
        using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
        {
            if (targets.Length == 1)
            {
                var akEvent      = (AkEvent)target;
                var eventPlaying = AkEditorEventPlayer.IsEventPlaying(akEvent);
                if (eventPlaying)
                {
                    if (UnityEngine.GUILayout.Button("Stop"))
                    {
                        UnityEngine.GUIUtility.hotControl = 0;
                        AkEditorEventPlayer.StopEvent(akEvent);
                    }
                }
                else
                {
                    if (UnityEngine.GUILayout.Button("Play"))
                    {
                        UnityEngine.GUIUtility.hotControl = 0;
                        AkEditorEventPlayer.PlayEvent(akEvent);
                    }
                }
            }
            else
            {
                var playingEventsSelected = false;
                var stoppedEventsSelected = false;
                for (var i = 0; i < targets.Length; ++i)
                {
                    var akEventTarget = targets[i] as AkEvent;
                    if (akEventTarget != null)
                    {
                        if (AkEditorEventPlayer.IsEventPlaying(akEventTarget))
                        {
                            playingEventsSelected = true;
                        }
                        else
                        {
                            stoppedEventsSelected = true;
                        }

                        if (playingEventsSelected && stoppedEventsSelected)
                        {
                            break;
                        }
                    }
                }

                if (stoppedEventsSelected &&
                    UnityEngine.GUILayout.Button("Play Multiple"))
                {
                    for (var i = 0; i < targets.Length; ++i)
                    {
                        var akEventTarget = targets[i] as AkEvent;
                        if (akEventTarget != null)
                        {
                            AkEditorEventPlayer.PlayEvent(akEventTarget);
                        }
                    }
                }

                if (playingEventsSelected &&
                    UnityEngine.GUILayout.Button("Stop Multiple"))
                {
                    for (var i = 0; i < targets.Length; ++i)
                    {
                        var akEventTarget = targets[i] as AkEvent;
                        if (akEventTarget != null)
                        {
                            AkEditorEventPlayer.StopEvent(akEventTarget);
                        }
                    }
                }
            }

            if (UnityEngine.GUILayout.Button("Stop All"))
            {
                UnityEngine.GUIUtility.hotControl = 0;
                AkEditorEventPlayer.StopAll();
            }
        }
    }
Пример #2
0
    public override void OnChildInspectorGUI()
    {
        m_UnityEventHandlerInspector.OnGUI();

        UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);

        using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
        {
            UnityEditor.EditorGUILayout.PropertyField(enableActionOnEvent, new UnityEngine.GUIContent("Action On Event: "));

            if (enableActionOnEvent.boolValue)
            {
                UnityEditor.EditorGUILayout.PropertyField(actionOnEventType, new UnityEngine.GUIContent("Action On EventType: "));
                UnityEditor.EditorGUILayout.PropertyField(curveInterpolation, new UnityEngine.GUIContent("Curve Interpolation: "));
                UnityEditor.EditorGUILayout.Slider(transitionDuration, 0.0f, 60.0f, new UnityEngine.GUIContent("Fade Time (secs): "));
            }
        }

        UnityEngine.GUILayout.Space(UnityEditor.EditorGUIUtility.standardVerticalSpacing);

        using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
        {
            UnityEditor.EditorGUILayout.PropertyField(useCallbacks, new UnityEngine.GUIContent("Use Callback: "));

            if (useCallbacks.boolValue)
            {
                var emptyContent = new UnityEngine.GUIContent("");

                // ensure that there is always at least one entry since we are "using" callbacks
                if (callbackData.arraySize == 0)
                {
                    callbackData.arraySize = 1;
                }

                const float callbackSpacerWidth = 4;
                const float removeButtonWidth   = 20;
                var         rect = UnityEditor.EditorGUILayout.GetControlRect();
                var         callbackFieldWidth = (rect.width - removeButtonWidth) / 3;
                rect.width = callbackFieldWidth - callbackSpacerWidth;

                UnityEngine.GUI.Label(rect, "Game Object");

                rect.x += callbackFieldWidth;
                UnityEngine.GUI.Label(rect, "Callback Function");

                rect.x += callbackFieldWidth;
                UnityEngine.GUI.Label(rect, "Callback Flags");

                for (var i = 0; i < callbackData.arraySize; ++i)
                {
                    var data = callbackData.GetArrayElementAtIndex(i);
                    rect       = UnityEditor.EditorGUILayout.GetControlRect();
                    rect.width = callbackFieldWidth - callbackSpacerWidth;
                    UnityEditor.EditorGUI.PropertyField(rect, data.FindPropertyRelative("GameObject"), emptyContent);

                    rect.x += callbackFieldWidth;
                    UnityEditor.EditorGUI.PropertyField(rect, data.FindPropertyRelative("FunctionName"), emptyContent);

                    rect.x += callbackFieldWidth;
                    UnityEditor.EditorGUI.PropertyField(rect, data.FindPropertyRelative("Flags"), emptyContent);

                    rect.x    += callbackFieldWidth;
                    rect.width = removeButtonWidth;
                    if (UnityEngine.GUI.Button(rect, "X"))
                    {
                        callbackData.DeleteArrayElementAtIndex(i);
                    }
                }

                if (UnityEngine.GUI.Button(UnityEditor.EditorGUILayout.GetControlRect(), "Add"))
                {
                    var i    = callbackData.arraySize++;
                    var data = callbackData.GetArrayElementAtIndex(i);
                    data.FindPropertyRelative("GameObject").objectReferenceValue = null;
                    data.FindPropertyRelative("FunctionName").stringValue        = string.Empty;
                    data.FindPropertyRelative("Flags.value").intValue            = 0;
                }
            }
            else if (callbackData.arraySize == 1)
            {
                var data = callbackData.GetArrayElementAtIndex(0);
                if (data.FindPropertyRelative("GameObject").objectReferenceValue == null)
                {
                    if (string.IsNullOrEmpty(data.FindPropertyRelative("FunctionName").stringValue))
                    {
                        if (data.FindPropertyRelative("Flags.value").intValue == 0)
                        {
                            callbackData.arraySize = 0;
                        }
                    }
                }
            }
        }

        using (new UnityEditor.EditorGUILayout.VerticalScope("box"))
        {
            if (targets.Length == 1)
            {
                var akEvent      = (AkEvent)target;
                var eventPlaying = AkEditorEventPlayer.IsEventPlaying(akEvent);
                if (eventPlaying)
                {
                    if (UnityEngine.GUILayout.Button("Stop"))
                    {
                        UnityEngine.GUIUtility.hotControl = 0;
                        AkEditorEventPlayer.StopEvent(akEvent);
                    }
                }
                else
                {
                    if (UnityEngine.GUILayout.Button("Play"))
                    {
                        UnityEngine.GUIUtility.hotControl = 0;
                        AkEditorEventPlayer.PlayEvent(akEvent);
                    }
                }
            }
            else
            {
                var playingEventsSelected = false;
                var stoppedEventsSelected = false;
                for (var i = 0; i < targets.Length; ++i)
                {
                    var akEventTarget = targets[i] as AkEvent;
                    if (akEventTarget != null)
                    {
                        if (AkEditorEventPlayer.IsEventPlaying(akEventTarget))
                        {
                            playingEventsSelected = true;
                        }
                        else
                        {
                            stoppedEventsSelected = true;
                        }

                        if (playingEventsSelected && stoppedEventsSelected)
                        {
                            break;
                        }
                    }
                }

                if (stoppedEventsSelected &&
                    UnityEngine.GUILayout.Button("Play Multiple"))
                {
                    for (var i = 0; i < targets.Length; ++i)
                    {
                        var akEventTarget = targets[i] as AkEvent;
                        if (akEventTarget != null)
                        {
                            AkEditorEventPlayer.PlayEvent(akEventTarget);
                        }
                    }
                }

                if (playingEventsSelected &&
                    UnityEngine.GUILayout.Button("Stop Multiple"))
                {
                    for (var i = 0; i < targets.Length; ++i)
                    {
                        var akEventTarget = targets[i] as AkEvent;
                        if (akEventTarget != null)
                        {
                            AkEditorEventPlayer.StopEvent(akEventTarget);
                        }
                    }
                }
            }

            if (UnityEngine.GUILayout.Button("Stop All"))
            {
                UnityEngine.GUIUtility.hotControl = 0;
                AkEditorEventPlayer.StopAll();
            }
        }
    }