コード例 #1
0
        public void ApplyImage(StyleSheet sheet, StyleValueHandle[] handles, int specificity, ref StyleBackground property)
        {
            Texture2D source = null;

            StyleValueHandle handle = handles[0];

            if (handle.valueType == StyleValueType.Keyword)
            {
                if (handle.valueIndex != (int)StyleValueKeyword.None)
                {
                    Debug.LogWarning("Invalid keyword for image source " + (StyleValueKeyword)handle.valueIndex);
                }
                else
                {
                    // it's OK, we let none be assigned to the source
                }
            }
            else if (TryGetSourceFromHandle(sheet, handle, out source) == false)
            {
                // Load a stand-in picture to make it easier to identify which image element is missing its picture
                source = Panel.LoadResource("d_console.warnicon", typeof(Texture2D)) as Texture2D;
            }
            var value = new StyleBackground(source)
            {
                specificity = specificity
            };

            property.Apply(value, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity);
        }
コード例 #2
0
        private void SetPropertyValue(object newValue)
        {
            object val = StyleDebug.GetComputedStyleValue(m_SelectedElement.computedStyle, m_PropertyInfo.id);
            Type type = m_PropertyInfo.type;

            if (newValue == null || type == newValue.GetType())
            {
                val = newValue;
            }
            else
            {
                if (type == typeof(StyleBackground))
                {
                    val = new StyleBackground(newValue as Texture2D);
                }
                else
                {
                    var valueInfo = type.GetProperty("value");
                    try
                    {
                        valueInfo.SetValue(val, newValue, null);
                    }
                    catch (Exception)
                    {
                        Debug.LogError($"Invalid value for property '{m_PropertyName}'");
                        return;
                    }
                }
            }

            StyleDebug.SetInlineStyleValue(m_SelectedElement.style, m_PropertyInfo.id, val);
            SetSpecificity(StyleDebug.InlineSpecificity);
        }
コード例 #3
0
 /// <summary>
 /// loads the necessary graphics
 /// for the mute button
 /// </summary>
 private void LoadMuteToggleImages(VisualElement windowRoot)
 {
     //Reference to toggle checkmarck
     toggelImage = windowRoot.Q("unity-checkmark");
     //loading the mute texture from folder
     soundMute = new StyleBackground(Resources.Load <Texture2D>("Icons/Sound_mute"));
     //loading the unmute texture folder
     soundUp = new StyleBackground(Resources.Load <Texture2D>("Icons/Sound_Up"));
 }
コード例 #4
0
        private void SetPropertyValue(object newValue)
        {
            object val  = StyleDebug.GetComputedStyleValue(m_SelectedElement.computedStyle, m_PropertyInfo.id);
            Type   type = m_PropertyInfo.type;

            if (newValue == null)
            {
                if (type == typeof(StyleBackground))
                {
                    val = new StyleBackground();
                }

                if (type == typeof(StyleFont))
                {
                    val = new StyleFont();
                }
            }
            else if (type == newValue.GetType())
            {
                val = newValue;
            }
            else
            {
                if (type == typeof(StyleBackground))
                {
                    val = new StyleBackground(newValue as Texture2D);
                }
                else if (type == typeof(StyleEnum <Overflow>) && newValue is OverflowInternal)
                {
                    OverflowInternal newV = (OverflowInternal)newValue;
                    Overflow         v    = newV == OverflowInternal.Hidden ? Overflow.Hidden : Overflow.Visible;
                    val = new StyleEnum <Overflow>(v);
                }
                else
                {
                    var valueInfo = type.GetProperty("value");
                    try
                    {
                        valueInfo.SetValue(val, newValue, null);
                    }
                    catch (Exception)
                    {
                        Debug.LogError($"Invalid value for property '{m_PropertyName}'");
                        return;
                    }
                }
            }

            StyleDebug.SetInlineStyleValue(m_SelectedElement.style, m_PropertyInfo.id, val);
            SetSpecificity(StyleDebug.InlineSpecificity);
        }
コード例 #5
0
        public StyleBackground ReadStyleBackground(int index)
        {
            var source = new ImageSource();
            var value  = m_Values[index];

            if (value.handle.valueType == StyleValueType.Keyword)
            {
                if (value.handle.valueIndex != (int)StyleValueKeyword.None)
                {
                    Debug.LogWarning("Invalid keyword for image source " + (StyleValueKeyword)value.handle.valueIndex);
                }
                else
                {
                    // it's OK, we let none be assigned to the source
                }
            }
            else if (TryGetImageSourceFromValue(value, out source) == false)
            {
                // Load a stand-in picture to make it easier to identify which image element is missing its picture
                source.texture = Panel.LoadResource("d_console.warnicon", typeof(Texture2D)) as Texture2D;
            }

            StyleBackground sb;

            if (source.texture != null)
            {
                sb = new StyleBackground(source.texture)
                {
                    specificity = specificity
                }
            }
            ;
            else if (source.vectorImage != null)
            {
                sb = new StyleBackground(source.vectorImage)
                {
                    specificity = specificity
                }
            }
            ;
            else
            {
                sb = new StyleBackground()
                {
                    specificity = specificity
                }
            };
            return(sb);
        }
コード例 #6
0
        public bool TryGetValue(CustomStyleProperty <VectorImage> property, out VectorImage value)
        {
            CustomPropertyHandle propertyHandle;
            var tmp = new StyleBackground();

            if (m_CustomProperties != null && m_CustomProperties.TryGetValue(property.name, out propertyHandle))
            {
                s_StyleSheetApplicator.ApplyImage(propertyHandle.data, propertyHandle.handles, propertyHandle.specificity, ref tmp);
                value = tmp.value.vectorImage;
                return(true);
            }

            value = null;
            return(false);
        }
コード例 #7
0
        public StyleBackground ReadStyleBackground(int index)
        {
            ImageSource        imageSource        = default(ImageSource);
            StylePropertyValue stylePropertyValue = this.m_Values[this.m_CurrentValueIndex + index];
            bool flag = stylePropertyValue.handle.valueType == StyleValueType.Keyword;

            if (flag)
            {
                bool flag2 = stylePropertyValue.handle.valueIndex != 6;
                if (flag2)
                {
                    string            arg_68_0   = "Invalid keyword for image source ";
                    StyleValueKeyword valueIndex = (StyleValueKeyword)stylePropertyValue.handle.valueIndex;
                    Debug.LogWarning(arg_68_0 + valueIndex.ToString());
                }
            }
            else
            {
                bool flag3 = !StylePropertyReader.TryGetImageSourceFromValue(stylePropertyValue, this.dpiScaling, out imageSource);
                if (flag3)
                {
                    imageSource.texture = (Panel.LoadResource("d_console.warnicon", typeof(Texture2D), this.dpiScaling) as Texture2D);
                }
            }
            bool            flag4 = imageSource.texture != null;
            StyleBackground result;

            if (flag4)
            {
                result = new StyleBackground(imageSource.texture);
            }
            else
            {
                bool flag5 = imageSource.vectorImage != null;
                if (flag5)
                {
                    result = new StyleBackground(imageSource.vectorImage);
                }
                else
                {
                    result = default(StyleBackground);
                }
            }
            return(result);
        }
コード例 #8
0
        public StyleBackground ReadStyleBackground(int index)
        {
            var styleBackground = new StyleBackground(m_CurrentStyleValue.keyword);

            if (m_CurrentStyleValue.resource.IsAllocated)
            {
                var texture = m_CurrentStyleValue.resource.Target as Texture2D;
                if (texture != null)
                {
                    styleBackground = new StyleBackground(texture, m_CurrentStyleValue.keyword);
                }
                else
                {
                    var vectorImage = m_CurrentStyleValue.resource.Target as VectorImage;
                    if (vectorImage != null)
                    {
                        styleBackground = new StyleBackground(vectorImage, m_CurrentStyleValue.keyword);
                    }
                }
            }

            styleBackground.specificity = specificity;
            return(styleBackground);
        }
コード例 #9
0
        public void ApplyImage(StyleSheet sheet, StyleValueHandle[] handles, int specificity, ref StyleBackground property)
        {
            var styleBackground = new StyleBackground(currentStyleValue.keyword);

            if (currentStyleValue.resource.IsAllocated)
            {
                var vectorImage = currentStyleValue.resource.Target as VectorImage;
                if (vectorImage != null)
                {
                    styleBackground = new StyleBackground(vectorImage, currentStyleValue.keyword);
                }
                else
                {
                    var texture = currentStyleValue.resource.Target as Texture2D;
                    if (texture != null)
                    {
                        styleBackground = new StyleBackground(texture, currentStyleValue.keyword);
                    }
                }
            }

            styleBackground.specificity = specificity;
            property.Apply(styleBackground, StylePropertyApplyMode.Copy);
        }
コード例 #10
0
        internal void ApplyStyleProperty(IStylePropertyReader reader)
        {
            switch (reader.propertyID)
            {
            case StylePropertyID.AlignContent:
                StyleSheetApplicator.ApplyAlign(reader, ref alignContent);
                break;

            case StylePropertyID.AlignItems:
                StyleSheetApplicator.ApplyAlign(reader, ref alignItems);
                break;

            case StylePropertyID.AlignSelf:
                StyleSheetApplicator.ApplyAlign(reader, ref alignSelf);
                break;

            case StylePropertyID.BackgroundImage:
                backgroundImage = reader.ReadStyleBackground(0);
                break;

            case StylePropertyID.FlexBasis:
                flexBasis = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.FlexGrow:
                flexGrow = reader.ReadStyleFloat(0);
                break;

            case StylePropertyID.FlexShrink:
                flexShrink = reader.ReadStyleFloat(0);
                break;

            case StylePropertyID.Font:
                unityFont = reader.ReadStyleFont(0);
                break;

            case StylePropertyID.FontSize:
                fontSize = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.FontStyleAndWeight:
                unityFontStyleAndWeight = reader.ReadStyleEnum <FontStyle>(0);
                break;

            case StylePropertyID.FlexDirection:
                flexDirection = reader.ReadStyleEnum <FlexDirection>(0);
                break;

            case StylePropertyID.FlexWrap:
                flexWrap = reader.ReadStyleEnum <Wrap>(0);
                break;

            case StylePropertyID.Height:
                height = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.JustifyContent:
                justifyContent = reader.ReadStyleEnum <Justify>(0);
                break;

            case StylePropertyID.MarginLeft:
                marginLeft = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.MarginTop:
                marginTop = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.MarginRight:
                marginRight = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.MarginBottom:
                marginBottom = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.MaxHeight:
                maxHeight = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.MaxWidth:
                maxWidth = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.MinHeight:
                minHeight = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.MinWidth:
                minWidth = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.Overflow:
                overflow = reader.ReadStyleEnum <OverflowInternal>(0);
                break;

            case StylePropertyID.OverflowClipBox:
                unityOverflowClipBox = reader.ReadStyleEnum <OverflowClipBox>(0);
                break;

            case StylePropertyID.PaddingLeft:
                paddingLeft = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.PaddingTop:
                paddingTop = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.PaddingRight:
                paddingRight = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.PaddingBottom:
                paddingBottom = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.Position:
                position = reader.ReadStyleEnum <Position>(0);
                break;

            case StylePropertyID.PositionTop:
                top = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.PositionBottom:
                bottom = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.PositionLeft:
                left = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.PositionRight:
                right = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.UnityTextAlign:
                unityTextAlign = reader.ReadStyleEnum <TextAnchor>(0);
                break;

            case StylePropertyID.Color:
                color = reader.ReadStyleColor(0);
                break;

            case StylePropertyID.Width:
                width = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.WhiteSpace:
                whiteSpace = reader.ReadStyleEnum <WhiteSpace>(0);
                break;

            case StylePropertyID.BackgroundColor:
                backgroundColor = reader.ReadStyleColor(0);
                break;

            case StylePropertyID.BackgroundScaleMode:
                unityBackgroundScaleMode = reader.ReadStyleEnum <ScaleMode>(0);
                break;

            case StylePropertyID.BackgroundImageTintColor:
                unityBackgroundImageTintColor = reader.ReadStyleColor(0);
                break;

            case StylePropertyID.BorderLeftColor:
                borderLeftColor = reader.ReadStyleColor(0);
                break;

            case StylePropertyID.BorderTopColor:
                borderTopColor = reader.ReadStyleColor(0);
                break;

            case StylePropertyID.BorderRightColor:
                borderRightColor = reader.ReadStyleColor(0);
                break;

            case StylePropertyID.BorderBottomColor:
                borderBottomColor = reader.ReadStyleColor(0);
                break;

            case StylePropertyID.BorderLeftWidth:
                borderLeftWidth = reader.ReadStyleFloat(0);
                break;

            case StylePropertyID.BorderTopWidth:
                borderTopWidth = reader.ReadStyleFloat(0);
                break;

            case StylePropertyID.BorderRightWidth:
                borderRightWidth = reader.ReadStyleFloat(0);
                break;

            case StylePropertyID.BorderBottomWidth:
                borderBottomWidth = reader.ReadStyleFloat(0);
                break;

            case StylePropertyID.BorderTopLeftRadius:
                borderTopLeftRadius = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.BorderTopRightRadius:
                borderTopRightRadius = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.BorderBottomRightRadius:
                borderBottomRightRadius = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.BorderBottomLeftRadius:
                borderBottomLeftRadius = reader.ReadStyleLength(0);
                break;

            case StylePropertyID.Cursor:
                cursor = reader.ReadStyleCursor(0);
                break;

            case StylePropertyID.SliceLeft:
                unitySliceLeft = reader.ReadStyleInt(0);
                break;

            case StylePropertyID.SliceTop:
                unitySliceTop = reader.ReadStyleInt(0);
                break;

            case StylePropertyID.SliceRight:
                unitySliceRight = reader.ReadStyleInt(0);
                break;

            case StylePropertyID.SliceBottom:
                unitySliceBottom = reader.ReadStyleInt(0);
                break;

            case StylePropertyID.Opacity:
                opacity = reader.ReadStyleFloat(0);
                break;

            case StylePropertyID.Visibility:
                visibility = reader.ReadStyleEnum <Visibility>(0);
                break;

            case StylePropertyID.Display:
                StyleSheetApplicator.ApplyDisplay(reader, ref display);
                break;

            default:
                throw new ArgumentException(string.Format("Non exhaustive switch statement (value={0})", reader.propertyID));
            }
        }
コード例 #11
0
        private void SetPropertyValue(object newValue)
        {
            object val  = StyleDebug.GetComputedStyleActualValue(m_SelectedElement.computedStyle, m_PropertyInfo.id);
            Type   type = m_PropertyInfo.type;

            if (newValue == null)
            {
                if (type == typeof(StyleBackground))
                {
                    val = new StyleBackground();
                }

                if (type == typeof(StyleFont))
                {
                    val = new StyleFont();
                }
            }
            else if (type == newValue.GetType())
            {
                // For StyleLengthField
                val = newValue;
            }
            else
            {
                if (type == typeof(StyleBackground))
                {
                    val = new StyleBackground(newValue as Texture2D);
                }
                else if (type == typeof(StyleFontDefinition))
                {
                    val = new StyleFontDefinition(newValue);
                }
                else if (val is TextShadow textShadow)
                {
                    if (newValue is Color newColor)
                    {
                        textShadow.color = newColor;
                    }
                    if (newValue is Vector2 newOffset)
                    {
                        textShadow.offset = newOffset;
                    }
                    if (newValue is float newBlur)
                    {
                        textShadow.blurRadius = newBlur;
                    }

                    val = new StyleTextShadow(textShadow);
                }
                else if (type == typeof(StyleEnum <Overflow>) && newValue is OverflowInternal)
                {
                    OverflowInternal newV = (OverflowInternal)newValue;
                    Overflow         v    = newV == OverflowInternal.Hidden ? Overflow.Hidden : Overflow.Visible;
                    val = new StyleEnum <Overflow>(v);
                }
                else
                {
                    var underlyingType = type.GetProperty("value").PropertyType;
                    var ctor           = type.GetConstructor(new[] { underlyingType });
                    try
                    {
                        val = ctor.Invoke(new[] { newValue });
                    }
                    catch (Exception)
                    {
                        Debug.LogError($"Invalid value for property '{m_PropertyName}'");
                        return;
                    }
                }
            }

            StyleDebug.SetInlineStyleValue(m_SelectedElement.style, m_PropertyInfo.id, val);
            SetSpecificity(StyleDebug.InlineSpecificity);
        }
コード例 #12
0
        private void SetPropertyValue(object newValue)
        {
            object val  = StyleDebug.GetComputedStyleValue(m_SelectedElement.computedStyle, m_PropertyInfo.id);
            Type   type = m_PropertyInfo.type;

            if (newValue == null)
            {
                if (type == typeof(StyleBackground))
                {
                    val = new StyleBackground();
                }

                if (type == typeof(StyleFont))
                {
                    val = new StyleFont();
                }

                if (type == typeof(StyleFontDefinition))
                {
                    val = new StyleFontDefinition();
                }
            }
            else if (type == newValue.GetType())
            {
                // For StyleLengthField
                val = newValue;
            }
            else
            {
                if (type == typeof(StyleBackground))
                {
                    val = new StyleBackground(newValue as Texture2D);
                }
                else if (type == typeof(StyleFontDefinition))
                {
                    val = new StyleFontDefinition(newValue);
                }
                else if (val is TextShadow textShadow)
                {
                    if (newValue is Color newColor)
                    {
                        textShadow.color = newColor;
                    }
                    if (newValue is Vector2 newOffset)
                    {
                        textShadow.offset = newOffset;
                    }
                    if (newValue is float newBlur)
                    {
                        textShadow.blurRadius = newBlur;
                    }

                    val = new StyleTextShadow(textShadow);
                }
                else if (type == typeof(StyleEnum <Overflow>) && newValue is OverflowInternal)
                {
                    OverflowInternal newV = (OverflowInternal)newValue;
                    Overflow         v    = newV == OverflowInternal.Hidden ? Overflow.Hidden : Overflow.Visible;
                    val = new StyleEnum <Overflow>(v);
                }
                else if (val is Scale scale && newValue is Vector3 newScale)
                {
                    val = new StyleScale(new Scale(newScale));
                }
コード例 #13
0
        public void ApplyImage(StyleSheet sheet, StyleValueHandle[] handles, int specificity, ref StyleBackground property)
        {
            Texture2D texture = null;

            if (currentStyleValue.resource.IsAllocated)
            {
                texture = currentStyleValue.resource.Target as Texture2D;
            }

            property.Apply(new StyleBackground(texture, currentStyleValue.keyword)
            {
                specificity = specificity
            }, StylePropertyApplyMode.Copy);
        }
コード例 #14
0
        private void DrawProperties()
        {
            EditorGUILayout.LabelField(Styles.elementStylesContent, Styles.KInspectorTitle);

            m_SelectedElement.name = EditorGUILayout.TextField("Name", m_SelectedElement.name);
            EditorGUILayout.LabelField("Debug Id", m_SelectedElement.controlid.ToString());
            var textElement = m_SelectedElement as ITextElement;

            if (textElement != null)
            {
                textElement.text = EditorGUILayout.TextField("Text", textElement.text);
            }

            bool cacheContents = EditorGUILayout.Toggle("Cache Contents", m_SelectedElement.cacheAsBitmap);

            m_SelectedElement.cacheAsBitmap = cacheContents;
            if (m_SelectedElement.cacheAsBitmap && m_SelectedElement.computedStyle.overflow.value == Overflow.Visible)
            {
                EditorGUILayout.HelpBox("Bitmap caching will be ignored for this element because it's not clipped", MessageType.Warning);
            }

            m_SelectedElement.pickingMode = (PickingMode)EditorGUILayout.EnumPopup("Picking Mode", m_SelectedElement.pickingMode);

            if (m_SelectedElement.pseudoStates != 0)
            {
                EditorGUILayout.LabelField("Pseudo States", m_SelectedElement.pseudoStates.ToString());
            }
            else
            {
                EditorGUILayout.LabelField("Pseudo States", "None");
            }

            EditorGUILayout.LabelField("Focusable", m_SelectedElement.focusable.ToString());

            EditorGUILayout.LabelField("Layout", m_SelectedElement.layout.ToString());
            EditorGUILayout.LabelField("World Bound", m_SelectedElement.worldBound.ToString());
            EditorGUILayout.LabelField("World Clip", m_SelectedElement.worldClip.ToString());
            EditorGUILayout.LabelField("Bounding Box", m_SelectedElement.boundingBox.ToString());

            if (m_ClassList == null)
            {
                InitClassList();
            }
            m_ClassList.DoLayoutList();

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            m_DetailFilter = EditorGUILayout.ToolbarSearchField(m_DetailFilter);
            m_ShowAll      = GUILayout.Toggle(m_ShowAll, Styles.showAllContent, EditorStyles.toolbarButton);
            m_Sort         = GUILayout.Toggle(m_Sort, Styles.sortContent, EditorStyles.toolbarButton);
            GUILayout.EndHorizontal();

            var customProperties = m_SelectedElement.specifiedStyle.m_CustomProperties;

            if (customProperties != null && customProperties.Any())
            {
                foreach (KeyValuePair <string, CustomPropertyHandle> customProperty in customProperties)
                {
                    foreach (StyleValueHandle handle in customProperty.Value.handles)
                    {
                        EditorGUILayout.LabelField(customProperty.Key, customProperty.Value.data.ReadAsString(handle));
                    }
                }
            }

            foreach (PropertyInfo field in m_Sort ? k_SortedFieldInfos : k_FieldInfos)
            {
                if (!string.IsNullOrEmpty(m_DetailFilter) &&
                    field.Name.IndexOf(m_DetailFilter, StringComparison.InvariantCultureIgnoreCase) == -1)
                {
                    continue;
                }

                object val = field.GetValue(m_SelectedElement.computedStyle, null);
                EditorGUILayout.BeginHorizontal();
                EditorGUI.BeginChangeCheck();
                int specificity;

                if (val is StyleFloat)
                {
                    StyleFloat style = (StyleFloat)val;
                    specificity = style.specificity;
                    if (m_ShowAll || specificity != StyleValueExtensions.UndefinedSpecificity)
                    {
                        style.specificity = Int32.MaxValue;
                        style.value       = EditorGUILayout.FloatField(field.Name, ((StyleFloat)val).value);
                        val = style;
                    }
                }
                else if (val is StyleInt)
                {
                    StyleInt style = (StyleInt)val;
                    specificity = style.specificity;
                    if (m_ShowAll || specificity != StyleValueExtensions.UndefinedSpecificity)
                    {
                        style.specificity = Int32.MaxValue;
                        style.value       = EditorGUILayout.IntField(field.Name, ((StyleInt)val).value);
                        val = style;
                    }
                }
                else if (val is StyleLength)
                {
                    StyleLength style = (StyleLength)val;
                    specificity = style.specificity;
                    if (m_ShowAll || specificity != StyleValueExtensions.UndefinedSpecificity)
                    {
                        style.specificity = Int32.MaxValue;
                        style.value       = EditorGUILayout.FloatField(field.Name, ((StyleLength)val).value.value);
                        val = style;
                    }
                }
                else if (val is StyleColor)
                {
                    StyleColor style = (StyleColor)val;
                    specificity = style.specificity;
                    if (m_ShowAll || specificity != StyleValueExtensions.UndefinedSpecificity)
                    {
                        style.specificity = Int32.MaxValue;
                        style.value       = EditorGUILayout.ColorField(field.Name, ((StyleColor)val).value);
                        val = style;
                    }
                }
                else if (val is StyleFont)
                {
                    specificity = HandleReferenceProperty <Font>(field, ref val);
                }
                else if (val is StyleBackground)
                {
                    StyleBackground style = (StyleBackground)val;
                    specificity = style.specificity;
                    if (m_ShowAll || specificity != StyleValueExtensions.UndefinedSpecificity)
                    {
                        style.specificity = Int32.MaxValue;
                        Texture2D t = EditorGUILayout.ObjectField(field.Name, style.value.texture, typeof(Texture2D), false) as Texture2D;
                        style.value = new Background(t);
                        val         = style;
                    }
                }
                else if (val is StyleCursor)
                {
                    StyleCursor style = (StyleCursor)val;
                    specificity = style.specificity;
                    if (m_ShowAll || specificity != StyleValueExtensions.UndefinedSpecificity)
                    {
                        if (style.value.texture != null)
                        {
                            style.specificity = Int32.MaxValue;
                            var texture = EditorGUILayout.ObjectField(field.Name + "'s texture2D", style.value.texture, typeof(Texture2D), false) as Texture2D;
                            EditorGUILayout.EndHorizontal();

                            EditorGUILayout.BeginHorizontal();
                            EditorGUIUtility.wideMode = true;
                            var hotspot = EditorGUILayout.Vector2Field(field.Name + "'s hotspot", style.value.hotspot);

                            style.value = new Cursor()
                            {
                                texture = texture, hotspot = hotspot
                            };
                            val = style;
                        }
                        else
                        {
                            int  mouseId      = style.value.defaultCursorId;
                            Enum newEnumValue = EditorGUILayout.EnumPopup(field.Name, (MouseCursor)mouseId);

                            int toCompare = Convert.ToInt32(newEnumValue);
                            if (!Equals(mouseId, toCompare))
                            {
                                style.specificity = Int32.MaxValue;
                                style.value       = new Cursor()
                                {
                                    defaultCursorId = toCompare
                                };
                                val = style;
                            }
                        }
                    }
                }
                else
                {
                    Type type = val.GetType();
                    if (type.IsGenericType && type.GetGenericArguments()[0].IsEnum)
                    {
                        specificity = (int)type.GetProperty("specificity", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(val, null);
                        if (m_ShowAll || specificity != StyleValueExtensions.UndefinedSpecificity)
                        {
                            var  propInfo     = type.GetProperty("value");
                            Enum enumValue    = propInfo.GetValue(val, null) as Enum;
                            Enum newEnumValue = EditorGUILayout.EnumPopup(field.Name, enumValue);
                            if (!Equals(enumValue, newEnumValue))
                            {
                                propInfo.SetValue(val, newEnumValue, null);
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField(field.Name, val == null ? "null" : val.ToString());
                        specificity = StyleValueExtensions.UndefinedSpecificity;
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    string propertyName = field.Name;
                    var    inlineStyle  = typeof(IStyle).GetProperty(propertyName);
                    inlineStyle.SetValue(m_SelectedElement.style, val, null);
                }

                if (m_ShowAll || specificity != StyleValueExtensions.UndefinedSpecificity)
                {
                    string specificityString = "";
                    switch (specificity)
                    {
                    case StyleValueExtensions.UnitySpecificity:
                        specificityString = "unity stylesheet";
                        break;

                    case StyleValueExtensions.InlineSpecificity:
                        specificityString = "inline";
                        break;

                    case StyleValueExtensions.UndefinedSpecificity:
                        break;

                    default:
                        specificityString = specificity.ToString();
                        break;
                    }
                    GUILayout.Label(specificityString, GUILayout.MinWidth(200), GUILayout.ExpandWidth(false));
                }

                EditorGUILayout.EndHorizontal();
            }
        }