private void EndPreviewInstance() { this.previewUtility.Render(false, true); PreviewRenderUtility.SetEnabledRecursive(this.paletteInstance, false); Unsupported.SetRenderSettingsUseFogNoDirty(this.m_OldFog); }
private static void TeardownPreviewLightingAndFx(bool oldFog) { Unsupported.SetRenderSettingsUseFogNoDirty(oldFog); InternalEditorUtility.RemoveCustomLighting(); }
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); }