public TextureRenderer GetRenderer(TextureRendererType type) { switch (type) { case TextureRendererType.EdgeBlur: if (m_EdgeBlurTextureRenderer == null) { m_EdgeBlurTextureRenderer = new EdgeBlurTexture(); } return(m_EdgeBlurTextureRenderer); case TextureRendererType.FakeDepth: if (m_FakeDepthTextureRenderer == null) { m_FakeDepthTextureRenderer = new FakeDepthTexture(); } return(m_FakeDepthTextureRenderer); default: if (m_FakeDepthTextureRenderer == null) { m_FakeDepthTextureRenderer = new FakeDepthTexture(); } return(m_FakeDepthTextureRenderer); } }
private void DrawBakeSetting(Rect rect) { bool guienable = GUI.enabled; GUI.enabled = guienable && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None; GUI.BeginGroup(new Rect(rect.x + 5, rect.y + 5, rect.width - 10, rect.height - 10)); GUI.enabled = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable; GUI.Label(new Rect(0, 0, position.width - 10, 17), "区域设置"); m_MaxHeight = Mathf.Max(0, EditorGUI.FloatField(new Rect(0, 20, rect.width - 10, 17), new GUIContent("上方高度", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整上方高度直到超过所有物体"), m_MaxHeight)); m_MinHeight = Mathf.Max(0, EditorGUI.FloatField(new Rect(0, 40, rect.width - 10, 17), new GUIContent("下方高度", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整下方高度直到刚好超过水底最深处"), m_MinHeight)); GUI.enabled = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable && m_MeshGeneratorType == MeshGeneratorType.ModelFile; m_LocalCenter = EditorGUI.Vector2Field(new Rect(0, 60, rect.width - 10, 40), new GUIContent("位置偏移", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整渲染区域的坐标偏移"), m_LocalCenter); GUI.enabled = (int)m_TargetErrorDef <= (int)TargetErrorDef.WillReplaceMesh && m_TargetGameObject && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable; m_RotY = EditorGUI.FloatField(new Rect(0, 100, rect.width - 10, 17), new GUIContent("Y轴旋转", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "调整渲染区域的Y轴旋转"), m_RotY); GUI.Label(new Rect(0, 120, position.width - 10, 17), "渲染设置"); m_TextureRendererType = (TextureRendererType)EditorGUI.EnumPopup(new Rect(0, 140, rect.width - 10, 17), "贴图渲染器类型", m_TextureRendererType); GUILayout.BeginArea(new Rect(0, 160, rect.width - 10, rect.height - 160)); TextureRenderer renderer = textureRenderer; if (renderer != null) { renderer.DrawGUI(); } EditorGUILayout.Space(); GUILayout.BeginHorizontal(); if (GUILayout.Button("渲染", GUIStyleCache.GetStyle("ButtonLeft"), GUILayout.Width(rect.width * 0.5f - 5))) { if (renderer != null) { Vector2 size = m_MeshGeneratorFactory.GetSize(m_MeshGeneratorType); renderer.RenderDepthTexture(m_TargetGameObject, m_LocalCenter, size, Quaternion.Euler(90, m_RotY, 0), m_MaxHeight, m_MinHeight, ref m_Texture); } } GUI.enabled = m_Texture != null && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable; if (m_MeshGeneratorType != MeshGeneratorType.ModelFile) { if (GUILayout.Button("生成Mesh", GUIStyleCache.GetStyle("ButtonRight"))) { UnlitWaterUtils.GenerateMesh(m_TargetGameObject, m_Texture, meshGenerator); } } else { if (GUILayout.Button("应用到顶点色", GUIStyleCache.GetStyle("ButtonRight"))) { UnlitWaterUtils.ApplyToVertexColor(m_TargetGameObject, m_Texture, m_LocalCenter, m_MeshGeneratorFactory.GetSize(m_MeshGeneratorType), m_MinHeight, m_MaxHeight); } } GUILayout.EndHorizontal(); GUI.enabled = guienable; GUILayout.EndArea(); GUI.EndGroup(); }