/// <summary>
 /// Asks for a paste of all feedbacks in the source
 /// </summary>
 protected virtual void PasteAllAsNew()
 {
     serializedObject.Update();
     Undo.RecordObject(target, "Paste all MMFeedbacks");
     MMF_PlayerCopy.PasteAll(this);
     serializedObject.ApplyModifiedProperties();
 }
 protected virtual void ReplaceAll()
 {
     serializedObject.Update();
     Undo.RecordObject(target, "Replace all MMFeedbacks");
     TargetMmfPlayer.FeedbacksList.Clear();
     MMF_PlayerCopy.PasteAll(this);
     serializedObject.ApplyModifiedProperties();
 }
        protected virtual void DrawBottomBar()
        {
            // Draw add new item

            if (_mmfeedbacksList.arraySize > 0)
            {
                MMF_PlayerStyling.DrawSplitter();
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            {
                // Feedback list

                int newItem = EditorGUILayout.Popup(0, _typeDisplays) - 1;
                if (newItem >= 0)
                {
                    serializedObject.Update();
                    Undo.RecordObject(target, "Add new feedback");
                    AddFeedback(_typesAndNames[newItem].FeedbackType);
                    serializedObject.ApplyModifiedProperties();
                    PrefabUtility.RecordPrefabInstancePropertyModifications(TargetMmfPlayer);
                }

                // Paste feedback copy as new

                if (MMF_PlayerCopy.HasCopy())
                {
                    if (GUILayout.Button(_pasteAsNewText, EditorStyles.miniButton, _pasteAsNewOption))
                    {
                        PasteAsNew();
                    }
                }

                if (MMF_PlayerCopy.HasMultipleCopies())
                {
                    if (GUILayout.Button(_replaceAllText, EditorStyles.miniButton, _replaceAllOption))
                    {
                        ReplaceAll();
                    }
                    if (GUILayout.Button(_pasteAllAsNewText, EditorStyles.miniButton, _pasteAllAsNewOption))
                    {
                        PasteAllAsNew();
                    }
                }
            }

            if (!MMF_PlayerCopy.HasMultipleCopies())
            {
                if (GUILayout.Button(_copyAllText, EditorStyles.miniButton, _pasteAsNewOption))
                {
                    CopyAll();
                }
            }

            EditorGUILayout.EndHorizontal();
        }
 /// <summary>
 /// Asks for a full copy of the source
 /// </summary>
 protected virtual void CopyAll()
 {
     MMF_PlayerCopy.CopyAll(target as MMF_Player);
 }
        /// <summary>
        /// Copy the selected feedback
        /// </summary>
        protected virtual void CopyFeedback(int id)
        {
            MMF_Feedback feedback = TargetMmfPlayer.FeedbacksList[id];

            MMF_PlayerCopy.Copy(feedback);
        }
        protected virtual void DrawFeedbackHeader(int i)
        {
            MMF_PlayerStyling.DrawSplitter();
            _feedbackListProperty = _mmfeedbacksList.GetArrayElementAtIndex(i);

            // Retrieve feedback
            _feedbackListFeedback = TargetMmfPlayer.FeedbacksList[i];

            if (_feedbackListFeedback == null)
            {
                return;
            }

            // Draw header
            _feedbackListIsExpanded = _feedbackListProperty.isExpanded;
            _feedbackListLabel      = _feedbackListFeedback.Label;
            _feedbackListPause      = false;

            if (_feedbackListFeedback.Pause != null)
            {
                _feedbackListPause = true;
            }
            if ((_feedbackListFeedback.LooperPause == true) && (Application.isPlaying))
            {
                if ((_feedbackListFeedback as MMF_Looper).InfiniteLoop)
                {
                    _feedbackListLabel = _feedbackListLabel + _infiniteLoopText;
                }
                else
                {
                    _feedbackListLabel = _feedbackListLabel + "[ " + (_feedbackListFeedback as MMF_Looper).NumberOfLoopsLeft + " loops left ] ";
                }
            }

            Rect headerRect = MMF_PlayerStyling.DrawHeader(
                ref _feedbackListIsExpanded,
                ref _feedbackListFeedback.Active,
                _feedbackListLabel,
                _feedbackListFeedback.FeedbackColor,
                (GenericMenu menu) =>
            {
                if (Application.isPlaying)
                {
                    menu.AddItem(_feedbackPlayGUIContent, false, () => PlayFeedback(i));
                }
                else
                {
                    menu.AddDisabledItem(_feedbackPlayGUIContent);
                }
                menu.AddSeparator(null);
                menu.AddItem(_feedbackRemoveGUIContent, false, () => RemoveFeedback(i));
                menu.AddSeparator(null);
                menu.AddItem(_feedbackCopyGUIContent, false, () => CopyFeedback(i));
                if (MMF_PlayerCopy.HasCopy())
                {
                    menu.AddItem(_feedbackPasteGUIContent, false, PasteAsNew);
                }
                else
                {
                    menu.AddDisabledItem(_feedbackPasteGUIContent);
                }
            },
                _feedbackListFeedback.FeedbackStartedAt,
                _feedbackListFeedback.FeedbackDuration,
                _feedbackListFeedback.TotalDuration,
                _feedbackListFeedback.Timing,
                _feedbackListPause,
                _feedbackListFeedback.RequiresSetup,
                _feedbackListFeedback.RequiredTarget,
                _feedbackListFeedback.DisplayColor,
                TargetMmfPlayer
                );

            // Check if we start dragging this feedback

            switch (_currentEvent.type)
            {
            case EventType.MouseDown:
                if (headerRect.Contains(_currentEvent.mousePosition))
                {
                    _draggedStartID = i;
                    _currentEvent.Use();
                }
                break;
            }

            // Draw blue rect if feedback is being dragged

            if (_draggedStartID == i && headerRect != Rect.zero)
            {
                EditorGUI.DrawRect(headerRect, _draggedColor);
            }

            // If hovering at the top of the feedback while dragging one, check where the feedback should be dropped : top or bottom

            if (headerRect.Contains(_currentEvent.mousePosition))
            {
                if (_draggedStartID >= 0)
                {
                    _draggedEndID = i;
                    Rect headerSplit = headerRect;
                    headerSplit.height *= 0.5f;
                    headerSplit.y      += headerSplit.height;
                    if (headerSplit.Contains(_currentEvent.mousePosition))
                    {
                        _draggedEndID = i + 1;
                    }
                }
            }
        }