예제 #1
0
 /// <summary>
 /// Preforms a capture of an editor window.
 /// </summary>
 /// <param name="editor">The window you want to take a capture of</param>
 public static void PreformCapture(EditorWindow editor)
 {
     _viewHeight          = editor.position.height;
     _viewWidth           = editor.position.width;
     _onRepaint           = editor.Repaint;
     _isPreformingCapture = 2;
     _viewYOffset         = 0f;
 }
예제 #2
0
 /// <summary>
 /// Preforms a capture of an editor.
 /// </summary>
 /// <param name="editor">The editor you want to take a capture of</param>
 public static void PreformCapture(Editor editor)
 {
     _viewHeight          = Screen.height;
     _viewWidth           = Screen.width;
     _onRepaint           = editor.Repaint;
     _isPreformingCapture = 2;
     // Inspectors have an offset
     _viewYOffset -= EditorGUIUtility.singleLineHeight;
 }
예제 #3
0
    /// <summary>
    /// Ends a capture group.
    /// </summary>
    public static void End()
    {
        EditorGUILayout.EndVertical();

        if (_isDebugEnabled || _isPreformingCapture > 0)
        {
            EventType currentEvent = Event.current.type;

            if (_isPreformingCapture > 0)
            {
                if ((currentEvent == EventType.Repaint || currentEvent == EventType.Layout) && currentEvent != _lastEvent)
                {
                    _lastEvent = currentEvent;

                    if (currentEvent == EventType.Repaint)
                    {
                        _isPreformingCapture--;
                    }

                    if (_isPreformingCapture == 0)
                    {
                        _onRepaint = null;
                        AssetDatabase.Refresh();
                    }
                    else
                    {
                        _onRepaint.Invoke();
                    }
                }
            }

            switch (currentEvent)
            {
            case EventType.Repaint:
                CaptureState state = _captureStack.Pop();
                if (_isDebugEnabled)
                {
                    _cachedContent.text = state.SavePath;
                    _debugStyle.Draw(state.Bounds, _cachedContent, true, false, false, false);
                }
                if (_isPreformingCapture == 1)
                {
                    Capture(state);
                }
                break;
            }
        }
    }