private void DoRenderPreview(bool shaded) { BillboardAsset billboardAsset = this.target as BillboardAsset; Bounds bounds = new Bounds(new Vector3(0f, (this.m_Height.floatValue + this.m_Bottom.floatValue) * 0.5f, 0f), new Vector3(this.m_Width.floatValue, this.m_Height.floatValue, this.m_Width.floatValue)); float magnitude = bounds.extents.magnitude; float num = 8f * magnitude; Quaternion quaternion = Quaternion.Euler(-this.m_PreviewDir.y, -this.m_PreviewDir.x, 0f); this.m_PreviewUtility.m_Camera.transform.rotation = quaternion; this.m_PreviewUtility.m_Camera.transform.position = quaternion * (-Vector3.forward * num); this.m_PreviewUtility.m_Camera.nearClipPlane = num - magnitude * 1.1f; this.m_PreviewUtility.m_Camera.farClipPlane = num + magnitude * 1.1f; this.m_PreviewUtility.m_Light[0].intensity = 1.4f; this.m_PreviewUtility.m_Light[0].transform.rotation = quaternion * Quaternion.Euler(40f, 40f, 0f); this.m_PreviewUtility.m_Light[1].intensity = 1.4f; Color ambient = new Color(0.1f, 0.1f, 0.1f, 0f); InternalEditorUtility.SetCustomLighting(this.m_PreviewUtility.m_Light, ambient); if (shaded) { billboardAsset.MakeRenderMesh(this.m_ShadedMesh, 1f, 1f, 0f); billboardAsset.MakeMaterialProperties(this.m_ShadedMaterialProperties, this.m_PreviewUtility.m_Camera); ModelInspector.RenderMeshPreviewSkipCameraAndLighting(this.m_ShadedMesh, bounds, this.m_PreviewUtility, billboardAsset.material, null, this.m_ShadedMaterialProperties, new Vector2(0f, 0f), -1); } else { billboardAsset.MakePreviewMesh(this.m_GeometryMesh); ModelInspector.RenderMeshPreviewSkipCameraAndLighting(this.m_GeometryMesh, bounds, this.m_PreviewUtility, this.m_GeometryMaterial, this.m_WireframeMaterial, null, new Vector2(0f, 0f), -1); } InternalEditorUtility.RemoveCustomLighting(); }
private void DoRenderPreview(bool shaded) { var billboard = target as BillboardAsset; Bounds bounds = new Bounds( new Vector3(0, (m_Height.floatValue + m_Bottom.floatValue) * 0.5f, 0), new Vector3(m_Width.floatValue, m_Height.floatValue, m_Width.floatValue)); float halfSize = bounds.extents.magnitude; float distance = 8.0f * halfSize; var rotation = Quaternion.Euler(-m_PreviewDir.y, -m_PreviewDir.x, 0); m_PreviewUtility.camera.transform.rotation = rotation; m_PreviewUtility.camera.transform.position = rotation * (-Vector3.forward * distance); m_PreviewUtility.camera.nearClipPlane = distance - halfSize * 1.1f; m_PreviewUtility.camera.farClipPlane = distance + halfSize * 1.1f; m_PreviewUtility.lights[0].intensity = 1.4f; m_PreviewUtility.lights[0].transform.rotation = rotation * Quaternion.Euler(40f, 40f, 0); m_PreviewUtility.lights[1].intensity = 1.4f; m_PreviewUtility.ambientColor = new Color(.1f, .1f, .1f, 0); if (shaded) { MakeRenderMesh(m_ShadedMesh, billboard); billboard.MakeMaterialProperties(m_ShadedMaterialProperties, m_PreviewUtility.camera); ModelInspector.RenderMeshPreviewSkipCameraAndLighting(m_ShadedMesh, bounds, m_PreviewUtility, billboard.material, null, m_ShadedMaterialProperties, new Vector2(0, 0), -1); } else { MakePreviewMesh(m_GeometryMesh, billboard); ModelInspector.RenderMeshPreviewSkipCameraAndLighting(m_GeometryMesh, bounds, m_PreviewUtility, m_GeometryMaterial, m_WireframeMaterial, null, new Vector2(0, 0), -1); } }
private void DrawMeshPreview(FrameDebuggerEvent curEvent, Rect previewRect, Rect meshInfoRect, Mesh mesh, int meshSubset) { if (this.m_PreviewUtility == null) { this.m_PreviewUtility = new PreviewRenderUtility(); this.m_PreviewUtility.m_CameraFieldOfView = 30f; } if (this.m_Material == null) { this.m_Material = EditorGUIUtility.GetBuiltinExtraResource(typeof(Material), "Default-Material.mat") as Material; } if (this.m_WireMaterial == null) { this.m_WireMaterial = ModelInspector.CreateWireframeMaterial(); } this.m_PreviewUtility.BeginPreview(previewRect, "preBackground"); ModelInspector.RenderMeshPreview(mesh, this.m_PreviewUtility, this.m_Material, this.m_WireMaterial, this.m_PreviewDir, meshSubset); this.m_PreviewUtility.EndAndDrawPreview(previewRect); string name = mesh.name; if (string.IsNullOrEmpty(name)) { name = "<no name>"; } object[] objArray1 = new object[] { name, " subset ", meshSubset, "\n", curEvent.vertexCount, " verts, ", curEvent.indexCount, " indices" }; string text = string.Concat(objArray1); EditorGUI.DropShadowLabel(meshInfoRect, text); }
private void DrawMeshPreview(FrameDebuggerEventData curEventData, Rect previewRect, Rect meshInfoRect, Mesh mesh, int meshSubset) { if (this.m_PreviewUtility == null) { this.m_PreviewUtility = new PreviewRenderUtility(); this.m_PreviewUtility.m_CameraFieldOfView = 30f; } if ((UnityEngine.Object) this.m_Material == (UnityEngine.Object)null) { this.m_Material = EditorGUIUtility.GetBuiltinExtraResource(typeof(Material), "Default-Material.mat") as Material; } if ((UnityEngine.Object) this.m_WireMaterial == (UnityEngine.Object)null) { this.m_WireMaterial = ModelInspector.CreateWireframeMaterial(); } this.m_PreviewUtility.BeginPreview(previewRect, (GUIStyle)"preBackground"); ModelInspector.RenderMeshPreview(mesh, this.m_PreviewUtility, this.m_Material, this.m_WireMaterial, this.m_PreviewDir, meshSubset); this.m_PreviewUtility.EndAndDrawPreview(previewRect); string str = mesh.name; if (string.IsNullOrEmpty(str)) { str = "<no name>"; } string text = str + " subset " + (object)meshSubset + "\n" + (object)curEventData.vertexCount + " verts, " + (object)curEventData.indexCount + " indices"; EditorGUI.DropShadowLabel(meshInfoRect, text); }
private void Init() { if (this.m_PreviewUtility == null) { this.m_PreviewUtility = new PreviewRenderUtility(); this.m_PreviewUtility.camera.fieldOfView = 30f; this.m_Material = (EditorGUIUtility.GetBuiltinExtraResource(typeof(Material), "Default-Material.mat") as Material); this.m_WireMaterial = ModelInspector.CreateWireframeMaterial(); } }
private void InitPreview() { if (m_PreviewUtility == null) { m_PreviewUtility = new PreviewRenderUtility(); m_ShadedMesh = new Mesh(); m_ShadedMesh.hideFlags = HideFlags.HideAndDontSave; m_ShadedMesh.MarkDynamic(); m_GeometryMesh = new Mesh(); m_GeometryMesh.hideFlags = HideFlags.HideAndDontSave; m_GeometryMesh.MarkDynamic(); m_ShadedMaterialProperties = new MaterialPropertyBlock(); m_GeometryMaterial = Material.GetDefaultMaterial(); m_WireframeMaterial = ModelInspector.CreateWireframeMaterial(); EditorUtility.SetCameraAnimateMaterials(m_PreviewUtility.camera, true); } }
private void InitPreview() { if (this.m_PreviewUtility == null) { this.m_PreviewUtility = new PreviewRenderUtility(); this.m_ShadedMesh = new Mesh(); this.m_ShadedMesh.hideFlags = HideFlags.HideAndDontSave; this.m_ShadedMesh.MarkDynamic(); this.m_GeometryMesh = new Mesh(); this.m_GeometryMesh.hideFlags = HideFlags.HideAndDontSave; this.m_GeometryMesh.MarkDynamic(); this.m_ShadedMaterialProperties = new MaterialPropertyBlock(); this.m_GeometryMaterial = (EditorGUIUtility.GetBuiltinExtraResource(typeof(Material), "Default-Material.mat") as Material); this.m_WireframeMaterial = ModelInspector.CreateWireframeMaterial(); EditorUtility.SetCameraAnimateMaterials(this.m_PreviewUtility.m_Camera, true); } }
internal static void RenderMeshPreview(Mesh mesh, PreviewRenderUtility previewUtility, Material litMaterial, Material wireMaterial, Vector2 direction, int meshSubset) { if (!(mesh == null) && previewUtility != null) { Bounds bounds = mesh.bounds; float magnitude = bounds.extents.magnitude; float num = 4f * magnitude; previewUtility.camera.transform.position = -Vector3.forward * num; previewUtility.camera.transform.rotation = Quaternion.identity; previewUtility.camera.nearClipPlane = num - magnitude * 1.1f; previewUtility.camera.farClipPlane = num + magnitude * 1.1f; previewUtility.lights[0].intensity = 1.4f; previewUtility.lights[0].transform.rotation = Quaternion.Euler(40f, 40f, 0f); previewUtility.lights[1].intensity = 1.4f; previewUtility.ambientColor = new Color(0.1f, 0.1f, 0.1f, 0f); ModelInspector.RenderMeshPreviewSkipCameraAndLighting(mesh, bounds, previewUtility, litMaterial, wireMaterial, null, direction, meshSubset); } }
private void DrawMeshPreview(FrameDebuggerEvent curEvent, Rect previewRect, Rect meshInfoRect, Mesh mesh, int meshSubset) { if (this.m_PreviewUtility == null) { this.m_PreviewUtility = new PreviewRenderUtility(); this.m_PreviewUtility.m_CameraFieldOfView = 30f; } if (this.m_Material == null) { this.m_Material = (EditorGUIUtility.GetBuiltinExtraResource(typeof(Material), "Default-Material.mat") as Material); } if (this.m_WireMaterial == null) { this.m_WireMaterial = new Material(ModelInspector.WireframeShaderSource); this.m_WireMaterial.hideFlags = HideFlags.HideAndDontSave; this.m_WireMaterial.shader.hideFlags = HideFlags.HideAndDontSave; } this.m_PreviewUtility.BeginPreview(previewRect, "preBackground"); ModelInspector.RenderMeshPreview(mesh, this.m_PreviewUtility, this.m_Material, this.m_WireMaterial, this.m_PreviewDir, meshSubset); Texture image = this.m_PreviewUtility.EndPreview(); GUI.DrawTexture(previewRect, image, ScaleMode.StretchToFill, false); string text = mesh.name; if (string.IsNullOrEmpty(text)) { text = "<no name>"; } string text2 = string.Concat(new object[] { text, " subset ", meshSubset, "\n", curEvent.vertexCount, " verts, ", curEvent.indexCount, " indices" }); EditorGUI.DropShadowLabel(meshInfoRect, text2); }
internal static void RenderMeshPreview(Mesh mesh, PreviewRenderUtility previewUtility, Material litMaterial, Material wireMaterial, Vector2 direction, int meshSubset) { if ((Object)mesh == (Object)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; previewUtility.m_Light[0].intensity = 1.4f; previewUtility.m_Light[0].transform.rotation = Quaternion.Euler(40f, 40f, 0.0f); previewUtility.m_Light[1].intensity = 1.4f; Color ambient = new Color(0.1f, 0.1f, 0.1f, 0.0f); InternalEditorUtility.SetCustomLighting(previewUtility.m_Light, ambient); ModelInspector.RenderMeshPreviewSkipCameraAndLighting(mesh, bounds, previewUtility, litMaterial, wireMaterial, (MaterialPropertyBlock)null, direction, meshSubset); InternalEditorUtility.RemoveCustomLighting(); }
private void DoRenderPreview() { ModelInspector.RenderMeshPreview(this.target as Mesh, this.m_PreviewUtility, this.m_Material, this.m_WireMaterial, this.previewDir, -1); }