Пример #1
0
    public override void OnInteractivePreviewGUI(Rect r, GUIStyle background)
    {
        if (lsdTarget.length == 0)
        {
            lsdTarget.length = lsdTarget.clip.length;
        }
#if UNITY_5_3_6 || UNITY_5_4_OR_NEWER
        if (lsdTarget.clip != null)
        {
            AudioUtility.DrawWaveForm(lsdTarget.clip, 0, new Rect(0, r.y + 3, EditorGUIUtility.currentViewWidth, r.height));
        }
#else
        if (waveform == null && lsdTarget.clip != null)
        {
            waveform = AudioUtility.GetWaveForm(lsdTarget.clip, 0, EditorGUIUtility.currentViewWidth, 128);
        }
        if (lsdTarget.clip != null && waveform != null)
        {
            GUI.DrawTexture(new Rect(0, r.y + 3, EditorGUIUtility.currentViewWidth, r.height), waveform);
        }
#endif
        //Playhead
        if (Event.current.button != 1)
        {
            seekPosition = GUI.HorizontalSlider(new Rect(0, r.y + 3, EditorGUIUtility.currentViewWidth, r.height), seekPosition, 0, 1, GUIStyle.none, GUIStyle.none);
        }

        GUI.DrawTexture(new Rect((seekPosition * EditorGUIUtility.currentViewWidth) - 3, r.y, 7, r.height), playhead_line);
        GUI.DrawTexture(new Rect((seekPosition * EditorGUIUtility.currentViewWidth) - 7, r.y, 15, 15), playhead_top);
        GUI.DrawTexture(new Rect((seekPosition * EditorGUIUtility.currentViewWidth) - 7, r.y + r.height - 16, 15, 15), playhead_bottom);

        if (Event.current.type == EventType.Repaint)
        {
            LipSyncEditorExtensions.DrawTimeline(r.y, 0, lsdTarget.length, r.width);
        }

        if (visualPreview && previewTarget != null)
        {
            EditorGUI.HelpBox(new Rect(20, r.y + r.height - 45, r.width - 40, 25), "Preview mode active. Note: only Phonemes and Emotions will be shown in the preview.", MessageType.Info);
        }
        else if (previewTarget != null)
        {
            UpdatePreview(0);
            previewTarget = null;
        }
    }
Пример #2
0
    public override void OnInteractivePreviewGUI(Rect r, GUIStyle background)
    {
        if (waveform == null && lsdTarget.clip != null)
        {
            waveform = AudioUtility.GetWaveForm(lsdTarget.clip, 0, EditorGUIUtility.currentViewWidth, 128);
        }

        if (lsdTarget.clip != null && waveform != null)
        {
            GUI.DrawTexture(new Rect(0, r.y + 3, EditorGUIUtility.currentViewWidth, r.height), waveform);
        }

        //Playhead
        if (Event.current.button != 1)
        {
            seekPosition = GUI.HorizontalSlider(new Rect(0, r.y + 3, EditorGUIUtility.currentViewWidth, r.height), seekPosition, 0, 1, GUIStyle.none, GUIStyle.none);
        }

        GUI.DrawTexture(new Rect((seekPosition * EditorGUIUtility.currentViewWidth) - 3, r.y, 7, r.height), playhead_line);
        GUI.DrawTexture(new Rect((seekPosition * EditorGUIUtility.currentViewWidth) - 7, r.y, 15, 15), playhead_top);
        GUI.DrawTexture(new Rect((seekPosition * EditorGUIUtility.currentViewWidth) - 7, r.y + r.height - 16, 15, 15), playhead_bottom);

        float pixelsPerSecond = r.width / lsdTarget.length;

        for (int a = 0; a < lsdTarget.length + 1; a++)
        {
            GUI.DrawTexture(new Rect((a * pixelsPerSecond), r.y + 1, 1, 12), marker_line);
            GUI.Box(new Rect((a * pixelsPerSecond) + 5, r.y, 30, 20), (a % 60).ToString().PadLeft(2, '0') + "s", EditorStyles.whiteMiniLabel);
        }

        if (visualPreview && previewTarget != null)
        {
            EditorGUI.HelpBox(new Rect(20, r.y + r.height - 45, r.width - 40, 25), "Preview mode active. Note: only Phonemes and Emotions will be shown in the preview.", MessageType.Info);
        }
        else if (previewTarget != null)
        {
            UpdatePreview(0);
            previewTarget = null;
        }
    }