private void RefreshFields() { if (m_SelectedElement == null) { return; } FindInlineStyles(); m_CustomPropertyFieldsContainer.Clear(); var customProperties = m_SelectedElement.computedStyle.m_CustomProperties; if (customProperties != null && customProperties.Any()) { foreach (KeyValuePair <string, StylePropertyValue> customProperty in customProperties) { var styleName = customProperty.Key; var propValue = customProperty.Value; TextField textField = new TextField(styleName) { isReadOnly = true }; textField.AddToClassList("unity-style-field"); textField.value = propValue.sheet.ReadAsString(propValue.handle).ToLower(); m_CustomPropertyFieldsContainer.Add(textField); } } foreach (var propertyInfo in s_StylePropertyInfos) { if (propertyInfo.isShorthand) { continue; } var styleName = propertyInfo.name; if (!string.IsNullOrEmpty(m_SearchFilter) && styleName.IndexOf(m_SearchFilter, StringComparison.InvariantCultureIgnoreCase) == -1) { continue; } var id = propertyInfo.id; object val = StyleDebug.GetComputedStyleValue(m_SelectedElement.computedStyle, id); Type type = propertyInfo.type; int specificity = 0; m_PropertySpecificityDictionary.TryGetValue(id, out specificity); StyleField sf = null; m_IdToFieldDictionary.TryGetValue(id, out sf); if (m_ShowAll || specificity != StyleDebug.UndefinedSpecificity) { if (sf != null) { sf.RefreshPropertyValue(val, specificity); } else { sf = new StyleField(m_SelectedElement, propertyInfo, val, specificity); m_FieldsContainer.Add(sf); m_IdToFieldDictionary[id] = sf; } } else if (sf != null) { // Style property is not applied anymore, remove the field m_IdToFieldDictionary.Remove(id); m_FieldsContainer.Remove(sf); } } }
private void RefreshFields() { if (m_SelectedElement == null) { return; } m_CustomPropertyFieldsContainer.Clear(); var customProperties = m_SelectedElement.specifiedStyle.m_CustomProperties; if (customProperties != null && customProperties.Any()) { foreach (KeyValuePair <string, CustomPropertyHandle> customProperty in customProperties) { var styleName = customProperty.Key; foreach (StyleValueHandle handle in customProperty.Value.handles) { TextField textField = new TextField(styleName) { isReadOnly = true }; textField.AddToClassList("unity-style-field"); textField.value = customProperty.Value.data.ReadAsString(handle).ToLower(); m_CustomPropertyFieldsContainer.Add(textField); } } } foreach (PropertyInfo propertyInfo in m_Sort ? k_SortedFieldInfos : k_FieldInfos) { var styleName = GetUSSPropertyNameFromComputedStyleName(propertyInfo.Name); if (!string.IsNullOrEmpty(m_SearchFilter) && styleName.IndexOf(m_SearchFilter, StringComparison.InvariantCultureIgnoreCase) == -1) { continue; } object val = propertyInfo.GetValue(selectedElement.computedStyle, null); Type type = val.GetType(); int specificity = (int)type.GetProperty("specificity", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(val, null); StyleField sf = null; m_NameToFieldDictionary.TryGetValue(styleName, out sf); if (m_ShowAll || specificity != StyleValueExtensions.UndefinedSpecificity) { if (sf != null) { sf.RefreshPropertyValue(val, specificity); } else { var sfPropInfo = new StyleFieldPropertyInfo() { name = styleName, value = val, specificity = specificity, computedPropertyInfo = propertyInfo }; sf = new StyleField(m_SelectedElement, sfPropInfo); m_FieldsContainer.Add(sf); m_NameToFieldDictionary[styleName] = sf; } } else if (sf != null) { // Style property is not applied anymore, remove the field m_NameToFieldDictionary.Remove(styleName); m_FieldsContainer.Remove(sf); } } }