DrawMesh() публичный Метод

public DrawMesh ( Mesh mesh, Matrix4x4 matrix, Material mat, int subMeshIndex ) : void
mesh UnityEngine.Mesh
matrix UnityEngine.Matrix4x4
mat UnityEngine.Material
subMeshIndex int
Результат void
Пример #1
0
        internal static void RenderMeshPreviewSkipCameraAndLighting(Mesh mesh, Bounds bounds, PreviewRenderUtility previewUtility, Material litMaterial, Material wireMaterial, MaterialPropertyBlock customProperties, Vector2 direction, int meshSubset)
        {
            if ((Object)mesh == (Object)null || previewUtility == null)
            {
                return;
            }
            Quaternion rot = Quaternion.Euler(direction.y, 0.0f, 0.0f) * Quaternion.Euler(0.0f, direction.x, 0.0f);
            Vector3    pos = rot * -bounds.center;
            bool       fog = RenderSettings.fog;

            Unsupported.SetRenderSettingsUseFogNoDirty(false);
            int subMeshCount = mesh.subMeshCount;

            if ((Object)litMaterial != (Object)null)
            {
                previewUtility.m_Camera.clearFlags = CameraClearFlags.Nothing;
                if (meshSubset < 0 || meshSubset >= subMeshCount)
                {
                    for (int subMeshIndex = 0; subMeshIndex < subMeshCount; ++subMeshIndex)
                    {
                        previewUtility.DrawMesh(mesh, pos, rot, litMaterial, subMeshIndex, customProperties);
                    }
                }
                else
                {
                    previewUtility.DrawMesh(mesh, pos, rot, litMaterial, meshSubset, customProperties);
                }
                previewUtility.m_Camera.Render();
            }
            if ((Object)wireMaterial != (Object)null)
            {
                previewUtility.m_Camera.clearFlags = CameraClearFlags.Nothing;
                GL.wireframe = true;
                if (meshSubset < 0 || meshSubset >= subMeshCount)
                {
                    for (int subMeshIndex = 0; subMeshIndex < subMeshCount; ++subMeshIndex)
                    {
                        previewUtility.DrawMesh(mesh, pos, rot, wireMaterial, subMeshIndex, customProperties);
                    }
                }
                else
                {
                    previewUtility.DrawMesh(mesh, pos, rot, wireMaterial, meshSubset, customProperties);
                }
                previewUtility.m_Camera.Render();
                GL.wireframe = false;
            }
            Unsupported.SetRenderSettingsUseFogNoDirty(fog);
        }
Пример #2
0
        void DrawPreview()
        {
            if (!SystemInfo.supports3DTextures)
            {
                return;
            }
            Texture3D texture = target as Texture3D;

            if (texture == null)
            {
                return;
            }
            if (!SystemInfo.supportsCompressed3DTextures && GraphicsFormatUtility.IsCompressedTextureFormat(texture.format))
            {
                return;
            }

            Quaternion rotation = Quaternion.Euler(-m_PreviewDir.y + s_InitialRotation.x, -m_PreviewDir.x + s_InitialRotation.y, 0);

            m_PreviewUtility.camera.transform.position = rotation * Vector3.back * m_ViewDistance;
            m_PreviewUtility.camera.transform.rotation = rotation;

            Vector3 scale = Vector3.one;

            switch (m_Preview3DMode)
            {
            case Preview3DMode.Volume:
                int sampleCount = PrepareVolumePreview(Materials.Volume, texture, scale, m_MaxAlpha, texture.filterMode,
                                                       m_Ramp, null, m_PreviewUtility.camera, Matrix4x4.identity, m_QualityModifier);
                GL.PushMatrix();
                GL.LoadProjectionMatrix(m_PreviewUtility.camera.projectionMatrix);
                Materials.Volume.SetPass(0);
                Graphics.DrawProceduralNow(MeshTopology.Quads, 4, sampleCount);
                GL.PopMatrix();
                return;

            case Preview3DMode.Slice:
                PrepareSlicePreview(Materials.Slice, texture, m_Slice, texture.filterMode, m_Ramp);
                m_PreviewUtility.DrawMesh(Handles.cubeMesh, Matrix4x4.Scale(scale + new Vector3(0.0001f, 0.0001f, 0.0001f)), Materials.Slice, 0);
                break;

            case Preview3DMode.SDF:
                PrepareSDFPreview(Materials.SDF, texture, scale, m_StepScale, m_SurfaceOffset);
                m_PreviewUtility.DrawMesh(Handles.cubeMesh, Matrix4x4.Scale(scale), Materials.SDF, 0);
                break;
            }

            m_PreviewUtility.Render();
        }
Пример #3
0
        void DrawPreview()
        {
            Texture3D texture = target as Texture3D;

            CalculateResolutionAndScale(texture);

            Quaternion rotation = Quaternion.Euler(-m_PreviewDir.y, 0, 0) * Quaternion.Euler(0, -m_PreviewDir.x, 0) * Quaternion.Euler(15, 30, 0);

            m_PreviewUtility.camera.transform.position = rotation * Vector3.back * m_ViewDistance;
            m_PreviewUtility.camera.transform.rotation = rotation;

            switch (m_Preview3DMode)
            {
            case Preview3DMode.Volume:
                s_MaterialVolume.mainTexture = texture;
                s_MaterialVolume.SetFloat(Props.invResolution, m_InvResolution);
                s_MaterialVolume.SetFloat(Props.quality, Mathf.Clamp(9 - Mathf.Log(1.0f / m_InvResolution, 2), 2, 8));
                s_MaterialVolume.SetVector(Props.invChannels, new Vector3(1 / m_Channels, 1 / m_Channels, 1 / m_Channels));
                s_MaterialVolume.SetFloat(Props.alpha, Mathf.Pow(m_MaxAlpha, 3));
                s_MaterialVolume.SetVector(Props.invScale, m_InvScale);
                s_MaterialVolume.SetFloat(Props.ramp, Convert.ToSingle(m_Ramp));

                m_PreviewUtility.DrawMesh(s_MeshCube, Matrix4x4.Scale(m_Scale), s_MaterialVolume, 0);
                break;

            case Preview3DMode.Slice:
                s_MaterialSliced.mainTexture = texture;
                Vector3 positions = new Vector3(m_Slice.x / m_Texture.width, m_Slice.y / m_Texture.height, m_Slice.z / m_Texture.depth) - new Vector3(0.5f, 0.5f, 0.5f);
                positions.Scale(m_Scale);
                s_MaterialSliced.SetVector(Props.positions, positions);
                s_MaterialSliced.SetVector(Props.invScale, m_InvScale);

                m_PreviewUtility.DrawMesh(s_MeshCube, Matrix4x4.Scale(m_Scale + new Vector3(0.0001f, 0.0001f, 0.0001f)), s_MaterialSliced, 0);
                break;

            case Preview3DMode.SDF:
                s_MaterialSDF.mainTexture = texture;
                s_MaterialSDF.SetFloat(Props.invResolution, m_InvResolution);
                s_MaterialSDF.SetFloat(Props.scale, m_HDRScale);
                s_MaterialSDF.SetFloat(Props.offset, m_HDROffset);
                s_MaterialSDF.SetVector(Props.invScale, m_InvScale);

                m_PreviewUtility.DrawMesh(s_MeshCube, Matrix4x4.Scale(m_Scale), s_MaterialSDF, 0);
                break;
            }

            m_PreviewUtility.Render();
        }
Пример #4
0
        private void RenderCubemap(Texture t, Vector2 previewDir, float previewDistance, float exposure)
        {
            m_PreviewUtility.camera.transform.position = -Vector3.forward * previewDistance;
            m_PreviewUtility.camera.transform.rotation = Quaternion.identity;
            Quaternion rot = Quaternion.Euler(previewDir.y, 0, 0) * Quaternion.Euler(0, previewDir.x, 0);

            m_Material.mainTexture = t;

            m_Material.SetMatrix(s_ShaderCubemapRotation, Matrix4x4.TRS(Vector3.zero, rot, Vector3.one));

            // -1 indicates "use regular sampling"; mips 0 and larger sample only that mip level for preview
            float mipLevel = GetMipLevelForRendering(t);

            m_Material.SetFloat(s_ShaderMip, mipLevel);
            m_Material.SetFloat(s_ShaderAlpha, (m_PreviewType == PreviewType.Alpha) ? 1.0f : 0.0f);
            m_Material.SetFloat(s_ShaderIntensity, m_Intensity);
            m_Material.SetFloat(s_ShaderIsNormalMap, TextureInspector.IsNormalMap(t) ? 1.0f : 0.0f);
            m_Material.SetFloat(s_ShaderExposure, exposure);

            if (PlayerSettings.colorSpace == ColorSpace.Linear)
            {
                m_Material.SetInt("_ColorspaceIsGamma", 0);
            }
            else
            {
                m_Material.SetInt("_ColorspaceIsGamma", 1);
            }

            m_PreviewUtility.DrawMesh(m_Mesh, Vector3.zero, rot, m_Material, 0);
            m_PreviewUtility.Render();
        }
Пример #5
0
		internal static void RenderMeshPreviewSkipCameraAndLighting(Mesh mesh, Bounds bounds, PreviewRenderUtility previewUtility, Material litMaterial, Material wireMaterial, MaterialPropertyBlock customProperties, Vector2 direction, int meshSubset)
		{
			if (mesh == null || previewUtility == null)
			{
				return;
			}
			Quaternion quaternion = Quaternion.Euler(direction.y, 0f, 0f) * Quaternion.Euler(0f, direction.x, 0f);
			Vector3 pos = quaternion * -bounds.center;
			bool fog = RenderSettings.fog;
			Unsupported.SetRenderSettingsUseFogNoDirty(false);
			int subMeshCount = mesh.subMeshCount;
			if (litMaterial != null)
			{
				previewUtility.m_Camera.clearFlags = CameraClearFlags.Nothing;
				if (meshSubset < 0 || meshSubset >= subMeshCount)
				{
					for (int i = 0; i < subMeshCount; i++)
					{
						previewUtility.DrawMesh(mesh, pos, quaternion, litMaterial, i, customProperties);
					}
				}
				else
				{
					previewUtility.DrawMesh(mesh, pos, quaternion, litMaterial, meshSubset, customProperties);
				}
				previewUtility.m_Camera.Render();
			}
			if (wireMaterial != null)
			{
				previewUtility.m_Camera.clearFlags = CameraClearFlags.Nothing;
				GL.wireframe = true;
				if (meshSubset < 0 || meshSubset >= subMeshCount)
				{
					for (int j = 0; j < subMeshCount; j++)
					{
						previewUtility.DrawMesh(mesh, pos, quaternion, wireMaterial, j, customProperties);
					}
				}
				else
				{
					previewUtility.DrawMesh(mesh, pos, quaternion, wireMaterial, meshSubset, customProperties);
				}
				previewUtility.m_Camera.Render();
				GL.wireframe = false;
			}
			Unsupported.SetRenderSettingsUseFogNoDirty(fog);
		}
Пример #6
0
 internal static void RenderMeshPreviewSkipCameraAndLighting(Mesh mesh, Bounds bounds, PreviewRenderUtility previewUtility, Material litMaterial, Material wireMaterial, MaterialPropertyBlock customProperties, Vector2 direction, int meshSubset)
 {
     if ((mesh != null) && (previewUtility != null))
     {
         Quaternion rot = Quaternion.Euler(direction.y, 0f, 0f) * Quaternion.Euler(0f, direction.x, 0f);
         Vector3    pos = (Vector3)(rot * -bounds.center);
         bool       fog = RenderSettings.fog;
         Unsupported.SetRenderSettingsUseFogNoDirty(false);
         int subMeshCount = mesh.subMeshCount;
         if (litMaterial != null)
         {
             previewUtility.m_Camera.clearFlags = CameraClearFlags.Nothing;
             if ((meshSubset < 0) || (meshSubset >= subMeshCount))
             {
                 for (int i = 0; i < subMeshCount; i++)
                 {
                     previewUtility.DrawMesh(mesh, pos, rot, litMaterial, i, customProperties);
                 }
             }
             else
             {
                 previewUtility.DrawMesh(mesh, pos, rot, litMaterial, meshSubset, customProperties);
             }
             previewUtility.m_Camera.Render();
         }
         if (wireMaterial != null)
         {
             previewUtility.m_Camera.clearFlags = CameraClearFlags.Nothing;
             GL.wireframe = true;
             if ((meshSubset < 0) || (meshSubset >= subMeshCount))
             {
                 for (int j = 0; j < subMeshCount; j++)
                 {
                     previewUtility.DrawMesh(mesh, pos, rot, wireMaterial, j, customProperties);
                 }
             }
             else
             {
                 previewUtility.DrawMesh(mesh, pos, rot, wireMaterial, meshSubset, customProperties);
             }
             previewUtility.m_Camera.Render();
             GL.wireframe = false;
         }
         Unsupported.SetRenderSettingsUseFogNoDirty(fog);
     }
 }
Пример #7
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            m_mouseDelta = CheckMouseMovement(m_mouseDelta, r);

            if (Event.current.type == EventType.Repaint)
            {
                m_previewRenderUtility.BeginPreview(r, background);

                Texture resultRender = m_previewRenderUtility.EndPreview();
                m_previewRenderUtility.DrawMesh(m_previewMesh, Matrix4x4.identity, m_material, 0);
                m_cameraTransform.rotation = Quaternion.Euler(new Vector3(-m_mouseDelta.y, -m_mouseDelta.x, 0));
                m_cameraTransform.position = m_cameraTransform.forward * -8f;
                m_previewRenderUtility.m_Camera.Render();

                GUI.DrawTexture(r, resultRender, ScaleMode.StretchToFill, false);
            }
        }
        private void RenderCubemap(Texture t, Vector2 previewDir, float previewDistance)
        {
            m_PreviewUtility.camera.transform.position = -Vector3.forward * previewDistance;
            m_PreviewUtility.camera.transform.rotation = Quaternion.identity;
            Quaternion rot = Quaternion.Euler(previewDir.y, 0, 0) * Quaternion.Euler(0, previewDir.x, 0);

            var mat = EditorGUIUtility.LoadRequired("Previews/PreviewCubemapMaterial.mat") as Material;

            mat.mainTexture = t;

            mat.SetMatrix("_CubemapRotation", Matrix4x4.TRS(Vector3.zero, rot, Vector3.one));

            // -1 indicates "use regular sampling"; mips 0 and larger sample only that mip level for preview
            float mipLevel = GetMipLevelForRendering(t);

            mat.SetFloat("_Mip", mipLevel);
            mat.SetFloat("_Alpha", (m_PreviewType == PreviewType.Alpha) ? 1.0f : 0.0f);
            mat.SetFloat("_Intensity", m_Intensity);

            m_PreviewUtility.DrawMesh(m_Mesh, Vector3.zero, rot, mat, 0);
            m_PreviewUtility.Render();
        }
        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);
        }
Пример #10
0
        internal static void RenderMeshPreviewSkipCameraAndLighting(
            Mesh mesh,
            Bounds bounds,
            PreviewRenderUtility previewUtility,
            PreviewSettings settings,
            MaterialPropertyBlock customProperties,
            int meshSubset) // -1 for whole mesh
        {
            if (mesh == null || previewUtility == null)
            {
                return;
            }

            Quaternion rot = Quaternion.Euler(settings.previewDir.y, 0, 0) * Quaternion.Euler(0, settings.previewDir.x, 0);
            Vector3    pos = rot * (-bounds.center);

            bool oldFog = RenderSettings.fog;

            Unsupported.SetRenderSettingsUseFogNoDirty(false);

            int submeshes     = mesh.subMeshCount;
            var tintSubmeshes = false;
            var colorPropID   = 0;

            if (submeshes > 1 && settings.displayMode == DisplayMode.Shaded && customProperties == null & meshSubset == -1)
            {
                tintSubmeshes    = true;
                customProperties = new MaterialPropertyBlock();
                colorPropID      = Shader.PropertyToID("_Color");
            }

            if (settings.activeMaterial != null)
            {
                previewUtility.camera.clearFlags = CameraClearFlags.Nothing;
                if (meshSubset < 0 || meshSubset >= submeshes)
                {
                    for (int i = 0; i < submeshes; ++i)
                    {
                        if (tintSubmeshes)
                        {
                            customProperties.SetColor(colorPropID, GetSubMeshTint(i));
                        }
                        previewUtility.DrawMesh(mesh, pos, rot, settings.activeMaterial, i, customProperties);
                    }
                }
                else
                {
                    previewUtility.DrawMesh(mesh, pos, rot, settings.activeMaterial, meshSubset, customProperties);
                }
                previewUtility.Render();
            }

            if (settings.wireMaterial != null && settings.drawWire)
            {
                previewUtility.camera.clearFlags = CameraClearFlags.Nothing;
                GL.wireframe = true;
                if (tintSubmeshes)
                {
                    customProperties.SetColor(colorPropID, settings.wireMaterial.color);
                }
                if (meshSubset < 0 || meshSubset >= submeshes)
                {
                    for (int i = 0; i < submeshes; ++i)
                    {
                        // lines/points already are wire-like; it does not make sense to overdraw
                        // them again with dark wireframe color
                        var topology = mesh.GetTopology(i);
                        if (topology == MeshTopology.Lines || topology == MeshTopology.LineStrip || topology == MeshTopology.Points)
                        {
                            continue;
                        }
                        previewUtility.DrawMesh(mesh, pos, rot, settings.wireMaterial, i, customProperties);
                    }
                }
                else
                {
                    previewUtility.DrawMesh(mesh, pos, rot, settings.wireMaterial, meshSubset, customProperties);
                }
                previewUtility.Render();
                GL.wireframe = false;
            }

            Unsupported.SetRenderSettingsUseFogNoDirty(oldFog);
        }
Пример #11
0
        internal static void RenderMeshPreviewSkipCameraAndLighting(
            Mesh mesh,
            Bounds bounds,
            PreviewRenderUtility previewUtility,
            Material litMaterial,
            Material wireMaterial,
            MaterialPropertyBlock customProperties,
            Vector2 direction,
            int meshSubset) // -1 for whole mesh
        {
            if (mesh == null || previewUtility == null)
            {
                return;
            }

            Quaternion rot = Quaternion.Euler(direction.y, 0, 0) * Quaternion.Euler(0, direction.x, 0);
            Vector3    pos = rot * (-bounds.center);

            bool oldFog = RenderSettings.fog;

            Unsupported.SetRenderSettingsUseFogNoDirty(false);

            int submeshes = mesh.subMeshCount;

            if (litMaterial != null)
            {
                previewUtility.camera.clearFlags = CameraClearFlags.Nothing;
                if (meshSubset < 0 || meshSubset >= submeshes)
                {
                    for (int i = 0; i < submeshes; ++i)
                    {
                        previewUtility.DrawMesh(mesh, pos, rot, litMaterial, i, customProperties);
                    }
                }
                else
                {
                    previewUtility.DrawMesh(mesh, pos, rot, litMaterial, meshSubset, customProperties);
                }
                previewUtility.Render();
            }

            if (wireMaterial != null)
            {
                previewUtility.camera.clearFlags = CameraClearFlags.Nothing;
                GL.wireframe = true;
                if (meshSubset < 0 || meshSubset >= submeshes)
                {
                    for (int i = 0; i < submeshes; ++i)
                    {
                        previewUtility.DrawMesh(mesh, pos, rot, wireMaterial, i, customProperties);
                    }
                }
                else
                {
                    previewUtility.DrawMesh(mesh, pos, rot, wireMaterial, meshSubset, customProperties);
                }
                previewUtility.Render();
                GL.wireframe = false;
            }

            Unsupported.SetRenderSettingsUseFogNoDirty(oldFog);
        }
Пример #12
0
		internal static void RenderMeshPreviewSkipCameraAndLighting(Mesh mesh, PreviewRenderUtility previewUtility, Material[] materials)
		{
			if (mesh == null || previewUtility == null)
			{
				return;
			}
			
			Bounds bounds = mesh.bounds;
			float magnitude = bounds.extents.magnitude;
			float num = 4f * magnitude;
			previewUtility.m_Camera.transform.position = -Vector3.forward * num;
			previewUtility.m_Camera.transform.rotation = Quaternion.identity;
			previewUtility.m_Camera.nearClipPlane = num - magnitude * 1.1f;
			previewUtility.m_Camera.farClipPlane = num + magnitude * 1.1f;
			
			Quaternion quaternion = Quaternion.identity;
			Vector3 pos = -bounds.center;
			bool fog = RenderSettings.fog;
			Unsupported.SetRenderSettingsUseFogNoDirty(false);
			int subMeshCount = mesh.subMeshCount;
			int meshSubset = materials.Length;
			if (materials != null && materials.Length > 0)
			{
				previewUtility.m_Camera.clearFlags = CameraClearFlags.Nothing;
				if (meshSubset < 0 || meshSubset >= subMeshCount)
				{
					for (int i = 0; i < subMeshCount; i++)
					{
						previewUtility.DrawMesh(mesh, pos, quaternion, materials[i], i);
					}
				}
				else
				{
					previewUtility.DrawMesh(mesh, pos, quaternion, materials[0], -1);
				}
				previewUtility.m_Camera.Render();
			}
			Unsupported.SetRenderSettingsUseFogNoDirty(fog);
		}
Пример #13
0
    private static void RenderMeshPreviewSkipCameraAndLighting(RoseMapObjectData mapObj, Matrix4x4[] mats, Bounds bounds, PreviewRenderUtility previewUtility, MaterialPropertyBlock customProperties, Vector2 direction)
    {
        bool fog = RenderSettings.fog;
        Unsupported.SetRenderSettingsUseFogNoDirty(false);

        Quaternion quaternion = Quaternion.Euler(direction.y, 0f, 0f) * Quaternion.Euler(0f, direction.x, 0f);
        Vector3 pos = quaternion * -bounds.center;
        Matrix4x4 rootTRS = new Matrix4x4();
        rootTRS.SetTRS(pos, quaternion, Vector3.one);

        for (var i = 0; i < mapObj.subObjects.Count; ++i)
        {
            var subObj = mapObj.subObjects[i];
            previewUtility.DrawMesh(subObj.mesh, rootTRS * mats[i], subObj.material, 0);
        }

        previewUtility.m_Camera.Render();
        Unsupported.SetRenderSettingsUseFogNoDirty(fog);
    }
Пример #14
0
 internal static void RenderMeshPreviewSkipCameraAndLighting(Mesh mesh, Bounds bounds, PreviewRenderUtility previewUtility, Material litMaterial, Material wireMaterial, MaterialPropertyBlock customProperties, Vector2 direction, int meshSubset)
 {
   if ((Object) mesh == (Object) null || previewUtility == null)
     return;
   Quaternion rot = Quaternion.Euler(direction.y, 0.0f, 0.0f) * Quaternion.Euler(0.0f, direction.x, 0.0f);
   Vector3 pos = rot * -bounds.center;
   bool fog = RenderSettings.fog;
   Unsupported.SetRenderSettingsUseFogNoDirty(false);
   int subMeshCount = mesh.subMeshCount;
   if ((Object) litMaterial != (Object) null)
   {
     previewUtility.m_Camera.clearFlags = CameraClearFlags.Nothing;
     if (meshSubset < 0 || meshSubset >= subMeshCount)
     {
       for (int subMeshIndex = 0; subMeshIndex < subMeshCount; ++subMeshIndex)
         previewUtility.DrawMesh(mesh, pos, rot, litMaterial, subMeshIndex, customProperties);
     }
     else
       previewUtility.DrawMesh(mesh, pos, rot, litMaterial, meshSubset, customProperties);
     previewUtility.m_Camera.Render();
   }
   if ((Object) wireMaterial != (Object) null)
   {
     previewUtility.m_Camera.clearFlags = CameraClearFlags.Nothing;
     GL.wireframe = true;
     if (meshSubset < 0 || meshSubset >= subMeshCount)
     {
       for (int subMeshIndex = 0; subMeshIndex < subMeshCount; ++subMeshIndex)
         previewUtility.DrawMesh(mesh, pos, rot, wireMaterial, subMeshIndex, customProperties);
     }
     else
       previewUtility.DrawMesh(mesh, pos, rot, wireMaterial, meshSubset, customProperties);
     previewUtility.m_Camera.Render();
     GL.wireframe = false;
   }
   Unsupported.SetRenderSettingsUseFogNoDirty(fog);
 }