Exemplo n.º 1
0
 private void DrawPicker(ref UndoParentNode owner, string content)
 {
     EditorGUILayout.BeginHorizontal();
     m_nodeId = owner.EditorGUILayoutIntPopup(content, m_nodeId, UIUtils.FloatIntNodeArr(), UIUtils.FloatIntNodeIds());
     if (GUILayout.Button(UIUtils.FloatIntIconOFF, UIUtils.FloatIntPickerONOFF, GUILayout.Width(15), GUILayout.Height(15)))
     {
         m_active = !m_active;
     }
     EditorGUILayout.EndHorizontal();
 }
 private void DrawPicker(ref UndoParentNode owner, string content)
 {
     EditorGUILayout.BeginHorizontal();
     string[] intArraysNames = owner.ContainerGraph.ParentWindow.CurrentGraph.FloatIntNodes.NodesArr;
     int[]    intIds         = owner.ContainerGraph.ParentWindow.CurrentGraph.FloatIntNodes.NodeIds;
     m_nodeId = owner.EditorGUILayoutIntPopup(content, m_nodeId, intArraysNames, intIds);
     if (GUILayout.Button(UIUtils.FloatIntIconOFF, UIUtils.FloatIntPickerONOFF, GUILayout.Width(15), GUILayout.Height(15)))
     {
         m_active = !m_active;
     }
     EditorGUILayout.EndHorizontal();
 }
Exemplo n.º 3
0
        //private int m_orderIndex = 1000;

        public void Draw(UndoParentNode owner, GUIStyle toolbarstyle, Material mat, bool connectedInput)
        {
            Color cachedColor = GUI.color;

            GUI.color = new Color(cachedColor.r, cachedColor.g, cachedColor.b, 0.5f);
            EditorGUILayout.BeginHorizontal(toolbarstyle);
            GUI.color = cachedColor;
            EditorGUI.BeginChangeCheck();
            m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation = GUILayout.Toggle(m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation, " Tessellation", UIUtils.MenuItemToggleStyle, GUILayout.ExpandWidth(true));
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetBool("ExpandedTesselation", m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation);
            }

            EditorGUI.BeginChangeCheck();
            m_enabled = owner.EditorGUILayoutToggle(string.Empty, m_enabled, UIUtils.MenuItemEnableStyle, GUILayout.Width(16));
            if (EditorGUI.EndChangeCheck())
            {
                if (m_enabled)
                {
                    UpdateToMaterial(mat, !connectedInput);
                }

                UIUtils.RequestSave();
            }

            EditorGUILayout.EndHorizontal();

            m_enabled = m_enabled || connectedInput;

            if (m_parentSurface.ContainerGraph.ParentWindow.ExpandedTesselation)
            {
                cachedColor = GUI.color;
                GUI.color   = new Color(cachedColor.r, cachedColor.g, cachedColor.b, (EditorGUIUtility.isProSkin ? 0.5f : 0.25f));
                EditorGUILayout.BeginVertical(UIUtils.MenuItemBackgroundStyle);
                GUI.color = cachedColor;

                EditorGUILayout.Separator();
                EditorGUI.BeginDisabledGroup(!m_enabled);

                EditorGUI.indentLevel += 1;

                m_phongEnabled = owner.EditorGUILayoutToggle(PhongEnableContent, m_phongEnabled);
                if (m_phongEnabled)
                {
                    EditorGUI.indentLevel += 1;
                    EditorGUI.BeginChangeCheck();
                    m_phongStrength = owner.EditorGUILayoutSlider(PhongStrengthContent, m_phongStrength, 0.0f, 1.0f);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(PhongStrengthUniformName))
                        {
                            mat.SetFloat(PhongStrengthUniformName, m_phongStrength);
                        }
                    }

                    EditorGUI.indentLevel -= 1;
                }

                bool guiEnabled = GUI.enabled;
                GUI.enabled = !connectedInput && m_enabled;

                m_tessType = owner.EditorGUILayoutIntPopup(TesselationTypeStr, m_tessType, TesselationTypeLabels, TesselationTypeValues);

                switch (m_tessType)
                {
                case 0:
                {
                    EditorGUI.BeginChangeCheck();
                    m_tessFactor = owner.EditorGUILayoutSlider(TessFactorContent, m_tessFactor, 1, 32);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(TessUniformName))
                        {
                            mat.SetFloat(TessUniformName, m_tessFactor);
                        }
                    }

                    EditorGUI.BeginChangeCheck();
                    m_tessMinDistance = owner.EditorGUILayoutFloatField(TessMinDistanceContent, m_tessMinDistance);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(TessMinUniformName))
                        {
                            mat.SetFloat(TessMinUniformName, m_tessMinDistance);
                        }
                    }

                    EditorGUI.BeginChangeCheck();
                    m_tessMaxDistance = owner.EditorGUILayoutFloatField(TessMaxDistanceContent, m_tessMaxDistance);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(TessMaxUniformName))
                        {
                            mat.SetFloat(TessMaxUniformName, m_tessMaxDistance);
                        }
                    }
                }
                break;

                case 1:
                {
                    EditorGUI.BeginChangeCheck();
                    m_tessFactor = owner.EditorGUILayoutSlider(TessFactorContent, m_tessFactor, 1, 32);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(TessUniformName))
                        {
                            mat.SetFloat(TessUniformName, m_tessFactor);
                        }
                    }
                }
                break;

                case 2:
                {
                    EditorGUI.BeginChangeCheck();
                    m_tessFactor = owner.EditorGUILayoutSlider(EdgeLengthContent, m_tessFactor, 2, 50);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(EdgeLengthTessUniformName))
                        {
                            mat.SetFloat(EdgeLengthTessUniformName, m_tessFactor);
                        }
                    }
                }
                break;

                case 3:
                {
                    EditorGUI.BeginChangeCheck();
                    m_tessFactor = owner.EditorGUILayoutSlider(EdgeLengthContent, m_tessFactor, 2, 50);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(EdgeLengthTessUniformName))
                        {
                            mat.SetFloat(EdgeLengthTessUniformName, m_tessFactor);
                        }
                    }

                    EditorGUI.BeginChangeCheck();
                    m_tessMaxDistance = owner.EditorGUILayoutFloatField(EdgeLengthTessMaxDisplacementContent, m_tessMaxDistance);
                    if (EditorGUI.EndChangeCheck() && mat != null)
                    {
                        if (mat.HasProperty(TessMinUniformName))
                        {
                            mat.SetFloat(TessMinUniformName, m_tessMaxDistance);
                        }
                    }
                }
                break;
                }
                GUI.enabled            = guiEnabled;
                EditorGUI.indentLevel -= 1;
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.Separator();
                EditorGUILayout.EndVertical();
            }
        }