private void DrawComputedStyle() { // style name, style value, source UIStyleSet style = selectedElement.style; bool isSet = (selectedElement.flags & UIElementFlags.DebugLayout) != 0; if (EditorGUILayout.ToggleLeft("Debug Layout", isSet)) { selectedElement.flags |= UIElementFlags.DebugLayout; } else { selectedElement.flags &= ~UIElementFlags.DebugLayout; } GUILayout.BeginHorizontal(); DrawStyleStateButton("Hover", StyleState.Hover); DrawStyleStateButton("Focus", StyleState.Focused); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); DrawStyleStateButton("Active", StyleState.Active); GUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); showAllComputedStyles = EditorGUILayout.ToggleLeft("Show All", showAllComputedStyles); showComputedSources = EditorGUILayout.ToggleLeft("Show Sources", showComputedSources); EditorGUILayout.EndHorizontal(); GUILayout.Space(4); searchString = searchField.OnGUI(searchString); GUILayout.Space(4); List <ValueTuple <string, StyleProperty> > properties = ListPool <ValueTuple <string, StyleProperty> > .Get(); string lowerSearch = searchString.ToLower(); for (int i = 0; i < StyleUtil.StylePropertyIdList.Length; i++) { StylePropertyId propertyId = StyleUtil.StylePropertyIdList[i]; if (showAllComputedStyles || style.IsDefined(propertyId)) { if (!string.IsNullOrEmpty(searchString)) { string propertyName = StyleUtil.GetPropertyName(propertyId).ToLower(); if (!propertyName.Contains(lowerSearch)) { continue; } } string source = selectedElement.style.GetPropertySource(propertyId); StyleProperty property = selectedElement.style.GetComputedStyleProperty(propertyId); if (!property.hasValue) { property = DefaultStyleValues_Generated.GetPropertyValue(propertyId); } properties.Add(ValueTuple.Create(source, property)); } } if (properties.Count == 0) { return; } if (showComputedSources) { properties.Sort( (a, b) => { if (a.Item1 == b.Item1) { return(0); } bool aInstance = a.Item1.Contains("Instance"); bool bInstance = b.Item1.Contains("Instance"); if (aInstance && bInstance) { return(string.Compare(a.Item1, b.Item1, StringComparison.Ordinal)); } if (aInstance) { return(-1); } if (bInstance) { return(1); } bool aDefault = a.Item1.Contains("Default"); bool bDefault = b.Item1.Contains("Default"); if (aDefault && bDefault) { return(string.Compare(a.Item1, b.Item1, StringComparison.Ordinal)); } if (aDefault) { return(1); } if (bDefault) { return(-1); } return(string.Compare(a.Item1, b.Item1, StringComparison.Ordinal)); }); GUILayout.Space(10); string currentSource = properties[0].Item1; EditorGUILayout.LabelField(currentSource); int start = 0; for (int i = 0; i < properties.Count; i++) { if (currentSource != properties[i].Item1) { properties.Sort(start, i - start, s_StyleCompare); for (int j = start; j < i; j++) { DrawStyleProperty(properties[j].Item2, false); } start = i; currentSource = properties[i].Item1; GUILayout.Space(10); EditorGUILayout.LabelField(currentSource); } } properties.Sort(start, properties.Count - start, s_StyleCompare); for (int j = start; j < properties.Count; j++) { DrawStyleProperty(properties[j].Item2, false); } } else { properties.Sort(0, properties.Count - 1, s_StyleCompare); for (int i = 0; i < properties.Count; i++) { DrawStyleProperty(properties[i].Item2, false); } } }