static Vector3?GetDefaultRange(Shader shader, String name)
        {
            var index = ShaderUtils.FindPropertyIndex(shader, name, ShaderUtil.ShaderPropertyType.Range);

            if (index >= 0)
            {
                return(new Vector3(
                           ShaderUtil.GetRangeLimits(shader, index, 0),
                           ShaderUtil.GetRangeLimits(shader, index, 1),
                           ShaderUtil.GetRangeLimits(shader, index, 2)));
            }
            else
            {
                index = ShaderUtils.FindPropertyIndex(shader, name, ShaderUtil.ShaderPropertyType.Float);
                if (index >= 0)
                {
                    return(new Vector3(ShaderUtil.GetRangeLimits(shader, index, 0), float.MinValue, float.MaxValue));
                }
            }
            return(null);
        }
        public void DrawGUI(Material material)
        {
            if (!ShaderGUIHelper.IsModeMatched(this, m_args) || !GetBoolTestResult(material, null))
            {
                if (m_autoReset && m_parent.template != null)
                {
                    if (m_dirty == null || m_dirty.Value == true)
                    {
                        m_dirty = false;
                        ResetToDefaultValue(m_parent.template);
                    }
                }
                return;
            }
            m_dirty = true;
            var gui_enabled = GUI.enabled;

            try {
                GUI.enabled = m_keep == null;
                if (!GUI.enabled && (m_prop.flags & MaterialProperty.PropFlags.HideInInspector) != 0)
                {
                    return;
                }
                m_MaterialEditor.SetDefaultGUIWidths();
                var   label = m_label ?? m_prop.displayName;
                float h     = m_MaterialEditor.GetPropertyHeight(m_prop, label);
                Rect  r     = EditorGUILayout.GetControlRect(true, h, EditorStyles.layerMaskField);
                for (; ;)
                {
                    if (m_guiType == Cfg.Value_PropGUIType_Toggle && (m_prop.type == MaterialProperty.PropType.Float || m_prop.type == MaterialProperty.PropType.Range))
                    {
                        m_prop.floatValue = EditorGUI.Toggle(r, label, m_prop.floatValue > 0) ? 1 : 0;
                        break;
                    }
                    if (m_guiType == Cfg.Value_PropGUIType_Rect && (m_prop.type == MaterialProperty.PropType.Vector))
                    {
                        var v      = m_prop.vectorValue;
                        var bounds = new Rect();
                        bounds.xMin = v.x;
                        bounds.xMax = v.y;
                        bounds.yMin = v.z;
                        bounds.yMax = v.w;
                        EditorGUI.LabelField(r, m_prop.displayName);
                        EditorGUI.indentLevel++;
                        bounds = EditorGUILayout.RectField(bounds);
                        EditorGUI.indentLevel--;
                        m_prop.vectorValue = new Vector4(bounds.xMin, bounds.xMax, bounds.yMin, bounds.yMax);
                        break;
                    }
                    if (m_prop.type == MaterialProperty.PropType.Color)
                    {
                        var precision = m_precision;
                        if (precision <= 0)
                        {
                            precision = 256;
                        }
                        if (m_guiType == Cfg.Value_PropGUIType_ColorR)
                        {
                            var c = m_prop.colorValue;
                            c.r = DrawRangeProperty(r, m_prop, m_prop.colorValue.r, label, 0, 1, precision);
                            m_prop.colorValue = c;
                            break;
                        }
                        else if (m_guiType == Cfg.Value_PropGUIType_ColorG)
                        {
                            var c = m_prop.colorValue;
                            c.g = DrawRangeProperty(r, m_prop, m_prop.colorValue.g, label, 0, 1, precision);
                            m_prop.colorValue = c;
                            break;
                        }
                        else if (m_guiType == Cfg.Value_PropGUIType_ColorB)
                        {
                            var c = m_prop.colorValue;
                            c.b = DrawRangeProperty(r, m_prop, m_prop.colorValue.b, label, 0, 1, precision);
                            m_prop.colorValue = c;
                            break;
                        }
                        else if (m_guiType == Cfg.Value_PropGUIType_ColorA)
                        {
                            var c = m_prop.colorValue;
                            c.a = DrawRangeProperty(r, m_prop, m_prop.colorValue.a, label, 0, 1, precision);
                            m_prop.colorValue = c;
                            break;
                        }
                    }
                    m_MaterialEditor.ShaderProperty(r, m_prop, label);
                    if (m_precision >= 0)
                    {
                        var range = new Vector3(0, float.MinValue, float.MaxValue);
                        if (m_prop.type == MaterialProperty.PropType.Float)
                        {
                            var index = ShaderUtils.FindPropertyIndex(material.shader, m_prop.name, ShaderUtil.ShaderPropertyType.Float);
                            if (index >= 0)
                            {
                                range.x = ShaderUtil.GetRangeLimits(material.shader, index, 0);
                            }
                            m_prop.floatValue = _RoundFloat(m_prop.floatValue, range);
                        }
                        else if (m_prop.type == MaterialProperty.PropType.Range)
                        {
                            range.y = m_prop.rangeLimits.x;
                            range.z = m_prop.rangeLimits.y;
                            var index = ShaderUtils.FindPropertyIndex(material.shader, m_prop.name, ShaderUtil.ShaderPropertyType.Range);
                            if (index >= 0)
                            {
                                range.x = ShaderUtil.GetRangeLimits(material.shader, index, 0);
                            }
                            m_prop.floatValue = _RoundFloat(m_prop.floatValue, range);
                        }
                        else if (m_prop.type == MaterialProperty.PropType.Color)
                        {
                            if (m_parent.template != null)
                            {
                                var _type = FindShaderPropertyType(m_parent.template.shader, m_prop.name);
                                if (_type != null && _type.Value == ShaderUtil.ShaderPropertyType.Color)
                                {
                                    var defaultColor = m_parent.template.GetColor(m_prop.name);
                                    var c            = m_prop.colorValue;
                                    c.r = _RoundColorFixed(c.r, new Vector3(defaultColor.r, 0, 1), m_precision);
                                    c.g = _RoundColorFixed(c.r, new Vector3(defaultColor.g, 0, 1), m_precision);
                                    c.b = _RoundColorFixed(c.r, new Vector3(defaultColor.b, 0, 1), m_precision);
                                    c.a = _RoundColorFixed(c.r, new Vector3(defaultColor.a, 0, 1), m_precision);
                                }
                            }
                        }
                    }
                    break;
                }
            } finally {
                GUI.enabled = gui_enabled;
            }
            m_MaterialEditor.SetDefaultGUIWidths();
        }