EndAndDrawPreview() public method

public EndAndDrawPreview ( Rect r ) : void
r UnityEngine.Rect
return void
Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (!ShaderUtil.hardwareSupportsRectRenderTexture)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40),
                                              "Mesh preview requires\nrender texture support");
                }
                return;
            }

            Init();

            Assembly   editorAssembly = Assembly.GetAssembly(typeof(EditorGUI));
            Type       guiPreview     = editorAssembly.GetType("PreviewGUI");
            MethodInfo drag2D         = guiPreview.GetMethod("Drag2D");

            if (m_Settings.displayMode != DisplayMode.UVLayout)
            {
                m_Settings.previewDir = (Vector2)drag2D?.Invoke(null, new object[] { m_Settings.previewDir, r });
            }
            //previewDir = PreviewGUI.Drag2D(previewDir, r);

            if (Event.current.type == EventType.ScrollWheel && m_Settings.displayMode == DisplayMode.UVLayout)
            {
                MeshPreviewZoom(r, Event.current);
            }

            if (Event.current.type == EventType.MouseDrag && m_Settings.displayMode == DisplayMode.UVLayout)
            {
                MeshPreviewPan(r, Event.current);
            }

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

            m_PreviewUtility.BeginPreview(r, background);

            DoRenderPreview();

            m_PreviewUtility.EndAndDrawPreview(r);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draws the preview GUI for the RuleTile
        /// </summary>
        /// <param name="rect">Rect to draw the preview GUI</param>
        /// <param name="background">The GUIStyle of the background for the preview</param>
        public override void OnPreviewGUI(Rect rect, GUIStyle background)
        {
            if (m_PreviewUtility == null)
            {
                CreatePreview();
            }

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

            m_PreviewUtility.BeginPreview(rect, background);
            m_PreviewUtility.camera.orthographicSize = 2;
            if (rect.height > rect.width)
            {
                m_PreviewUtility.camera.orthographicSize *= (float)rect.height / rect.width;
            }
            m_PreviewUtility.camera.Render();
            m_PreviewUtility.EndAndDrawPreview(rect);
        }
Exemplo n.º 4
0
 public override void OnPreviewGUI(Rect r, GUIStyle background)
 {
     if (!ShaderUtil.hardwareSupportsRectRenderTexture)
     {
         if (Event.current.type == EventType.Repaint)
         {
             EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40f), "Preview requires\nrender texture support");
         }
     }
     else
     {
         this.previewDir = PreviewGUI.Drag2D(this.previewDir, r);
         if (Event.current.type == EventType.Repaint)
         {
             PreviewRenderUtility renderUtility = this.GetPreviewData().renderUtility;
             renderUtility.BeginPreview(r, background);
             this.DoRenderPreview();
             renderUtility.EndAndDrawPreview(r);
         }
     }
 }
Exemplo n.º 5
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (!ShaderUtil.hardwareSupportsRectRenderTexture)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40),
                                              "Mesh preview requires\nrender texture support");
                }
                return;
            }

            Init();

            if (m_Settings.displayMode != DisplayMode.UVLayout)
            {
                m_Settings.previewDir = PreviewGUI.Drag2D(m_Settings.previewDir, r);
            }

            if (Event.current.type == EventType.ScrollWheel && m_Settings.displayMode == DisplayMode.UVLayout)
            {
                MeshPreviewZoom(r, Event.current);
            }

            if (Event.current.type == EventType.MouseDrag && m_Settings.displayMode == DisplayMode.UVLayout)
            {
                MeshPreviewPan(r, Event.current);
            }

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

            m_PreviewUtility.BeginPreview(r, background);

            DoRenderPreview();

            m_PreviewUtility.EndAndDrawPreview(r);
        }
        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;
            }

            m_PreviewDir = PreviewGUI.Drag2D(m_PreviewDir, r);

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

            InitPreview();
            m_Material.mainTexture = target as Texture;

            m_PreviewUtility.BeginPreview(r, background);
            bool oldFog = RenderSettings.fog;

            Unsupported.SetRenderSettingsUseFogNoDirty(false);

            m_PreviewUtility.camera.transform.position = -Vector3.forward * 3.0f;
            m_PreviewUtility.camera.transform.rotation = Quaternion.identity;
            Quaternion rot = Quaternion.Euler(m_PreviewDir.y, 0, 0) * Quaternion.Euler(0, m_PreviewDir.x, 0);

            m_PreviewUtility.DrawMesh(m_Mesh, Vector3.zero, rot, m_Material, 0);
            m_PreviewUtility.Render();

            Unsupported.SetRenderSettingsUseFogNoDirty(oldFog);
            m_PreviewUtility.EndAndDrawPreview(r);
        }