UnityEditor.PreviewRenderUtility.EndAndDrawPreview C# (CSharp) Method

EndAndDrawPreview() public method

public EndAndDrawPreview ( Rect r ) : void
r UnityEngine.Rect
return void
        public void EndAndDrawPreview(Rect r)
        {
            Texture image = this.EndPreview();
            GL.sRGBWrite = QualitySettings.activeColorSpace == ColorSpace.Linear;
            GUI.DrawTexture(r, image, ScaleMode.StretchToFill, false);
            GL.sRGBWrite = false;
        }

Usage Example

示例#1
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (!ShaderUtil.hardwareSupportsRectRenderTexture || !SystemInfo.supports3DTextures)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40), "3D texture preview not supported");
                }
                return;
            }
            Texture3D texture = target as Texture3D;

            if (texture == null)
            {
                return;
            }
            if (!SystemInfo.supportsCompressed3DTextures && GraphicsFormatUtility.IsCompressedTextureFormat(texture.format))
            {
                if (Event.current.type == EventType.Repaint)
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40), "Compressed 3D texture preview is not supported");
                }
                return;
            }

            InitPreviewUtility();
            Event e = Event.current;

            m_PreviewDir = PreviewGUI.Drag2D(m_PreviewDir, r);

            if (e.type == EventType.ScrollWheel)
            {
                m_ViewDistance = Mathf.Clamp(m_ViewDistance + e.delta.y * (0.01f + Mathf.Sqrt(m_ViewDistance) / 20), s_MinViewDistance, s_MaxViewDistance);
                e.Use();
                Repaint();
            }

            if (e.type != EventType.Repaint)
            {
                return;
            }

            m_PreviewUtility.BeginPreview(r, background);
            DrawPreview();
            m_PreviewUtility.EndAndDrawPreview(r);
        }
All Usage Examples Of UnityEditor.PreviewRenderUtility::EndAndDrawPreview