Пример #1
0
    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();
    }
Пример #2
0
    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_MaxDepth = Mathf.Max(0,
                               EditorGUI.FloatField(new Rect(0, 140, rect.width - 10, 17),
                                                    new GUIContent("最大深度范围", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "控制渲染的最大深度范围,默认为1"),
                                                    m_MaxDepth));
        m_DepthPower = Mathf.Max(0,
                                 EditorGUI.FloatField(new Rect(0, 160, rect.width - 10, 17),
                                                      new GUIContent("深度增强", EditorGUIUtility.FindTexture("console.erroricon.inactive.sml"), "控制渲染深度的效果增强或减弱,默认为1表示不增强"),
                                                      m_DepthPower));

        if (GUI.Button(new Rect(0, 220, (rect.width - 10) / 2, 16), "渲染", GUIStyleCache.GetStyle("ButtonLeft")))
        {
            Vector2 size = m_Factory.GetSize(m_MeshGeneratorType);
            UnlitWaterUtils.RenderDepthTexture(m_TargetGameObject, m_LocalCenter, size,
                                               Quaternion.Euler(90, m_RotY, 0), m_MaxHeight, m_MinHeight, m_MaxDepth, m_DepthPower, ref m_Texture);
        }
        GUI.enabled = m_Texture != null && m_Painter.paintVertexChannel == UnlitWaterPainter.Channel.None && guienable;
        if (m_MeshGeneratorType != MeshGeneratorType.ModelFile)
        {
            if (GUI.Button(new Rect((rect.width - 10) / 2, 220, (rect.width - 10) / 2, 16), "生成Mesh",
                           GUIStyleCache.GetStyle("ButtonRight")))
            {
                UnlitWaterUtils.GenerateMesh(m_TargetGameObject, m_Texture, meshGenerator);
            }
        }
        else
        {
            if (GUI.Button(new Rect((rect.width - 10) / 2, 220, (rect.width - 10) / 2, 16), "应用到顶点色",
                           GUIStyleCache.GetStyle("ButtonRight")))
            {
                UnlitWaterUtils.ApplyToVertexColor(m_TargetGameObject, m_Texture, m_LocalCenter, m_Factory.GetSize(m_MeshGeneratorType), m_MinHeight, m_MaxHeight);
            }
        }

        GUI.enabled = guienable;
        GUI.EndGroup();
    }