private static int GetMaxAbsId(ContainerEditorInfo.InnerObjectInfo info) { int maxAbsId = Math.Abs(info.Id); if (info.IsExpandable) { foreach (var inner in info.InnerObjects) { int innerId = Math.Abs(GetMaxAbsId(inner)); maxAbsId = maxAbsId > innerId ? maxAbsId : innerId; } } return(maxAbsId); }
private void ExpandOldWarnings(ContainerEditorInfo.InnerObjectInfo e) { if (!e.HasOldVersions | !e.IsExpandable) { return; } SetExpanded(e, true); foreach (var inner in e.InnerObjects) { if (inner.IsExpandable) { ExpandOldWarnings(inner); } } }
public ObjectContentPopupWindow(ContainerEditorInfo containerInfo, ContainerEditorInfo.InnerObjectInfo objInfo) { _containerInfo = containerInfo; _objectInfo = objInfo; if (_objectInfo.JsonData == null & _objectInfo.TotalSize <= AutoCreateJsonSize) { _containerInfo.UpdateJsonData(_objectInfo); } if (TextStyle == null) { TextStyle = new GUIStyle(EditorStyles.textArea); TextStyle.wordWrap = true; TextStyle.fontSize--; } }
private void SetExpanded(ContainerEditorInfo.InnerObjectInfo e, bool value, bool child = false) { var oldValue = _expandedObjects.Contains(e); if (!value & oldValue) { _expandedObjects.Remove(e); } if (value & !oldValue) { _expandedObjects.Add(e); } if (child & e.IsExpandable) { foreach (var inner in e.InnerObjects) { if (inner.IsExpandable) { SetExpanded(inner, value, true); } } } }
private Rect DrawEntry(ContainerEditorInfo.InnerObjectInfo e, float indent) { bool isRoot = _parentEntries.Count == 0; bool isVisible = GetNextLineVisible(out var pos, true); var lineRect = pos; if (isVisible) { // id var idRect = pos.SliceLeft(_idWidth); if (isRoot) { EditorGUI.DrawRect(pos, new Color(0.3f, 0.3f, 1f, 0.2f)); if (!e.HasOldVersions & !e.OldVersion) { EditorGUI.DrawRect(idRect, new Color(0.3f, 0.3f, 1f, 0.2f)); } } if (e.OldVersion) { EditorGUI.DrawRect(idRect, new Color(0.9f, 0.9f, 0.3f, 0.8f)); } else if (e.HasOldVersions) { EditorGUI.DrawRect(idRect, new Color(0.9f, 0.9f, 0.3f, 0.4f)); } if (e.Id != -1) { GUI.contentColor = isRoot ? Color.white : new Color(0.5f, 0.5f, 0.5f, 0.4f); EditorGUI.LabelField(idRect, e.Id.ToString(), isRoot ? BoldRight : NormalRight); } if (e.HasOldVersions && GUI.Button(idRect, GUIContent.none, GUIStyle.none)) { ExpandOldWarnings(e); } var collapseRect = pos.SliceLeft(indent); if (!isRoot && GUI.Button(collapseRect, "", GUIStyle.none)) { SetExpanded(_parentEntries.Peek(), false, Event.current.alt); } // expanded var expandRect = pos.SliceLeft(16f); bool expanded = e.IsExpandable && _expandedObjects.Contains(e); if (e.IsExpandable) { GUI.contentColor = Color.gray; if (GUI.Button(expandRect, expanded ? ShrinkButton : ExpandButton, BoldRight)) { SetExpanded(e, !expanded, Event.current.alt); } } // json var jsonRect = pos.SliceRight(19f); if (e.IsRealObject & !e.IsNull & e.IsSupported) { bool requiresJsonUpdate = e.JsonData == null; GUI.contentColor = new Color(1f, 1f, 1f, 0.5f); GUI.backgroundColor = requiresJsonUpdate ? Color.clear : !e.JsonHasErrors ? new Color(0.7f, 0.9f, 0.7f, 0.6f) : e.JsonCreated ? new Color(0.9f, 0.9f, 0.7f, 0.6f) : new Color(0.9f, 0.7f, 0.7f, 0.6f); if (GUI.Button(jsonRect, "D")) { PopupWindow.Show(jsonRect, new ObjectContentPopupWindow(Info, e)); } GUI.backgroundColor = Color.white; } var nameRect = pos; // size (persistent) { _tempContent.text = Size(RenderTotalSize ? e.TotalSize : e.DataSize); var width = BoldRight.CalcSize(_tempContent).x; nameRect.xMax = pos.xMax - width; GUI.contentColor = Color.white; EditorGUI.LabelField(pos.SliceRight(SizeWidth), _tempContent, BoldRight); } // size (optional) if (RenderSelfSize & e.SelfSize > 0) { _tempContent.text = Size(e.SelfSize); var width = BoldRight.CalcSize(_tempContent).x; nameRect.xMax = pos.xMax - width; GUI.contentColor = Color.gray; EditorGUI.LabelField(pos.SliceRight(SizeWidth), _tempContent, NormalRight); } // name GUI.contentColor = e.IsSupported ? e.IsNull ? Color.grey : Color.black : Color.red; if (GUI.Button(nameRect, RenderRefType ? e.Caption : e.TypeInfo.Type.PrettyName(), e.IsRealObject ? Bold : Normal) & e.IsExpandable) { SetExpanded(e, !expanded, Event.current.alt); } } // internal entries if (e.IsExpandable && _expandedObjects.Contains(e)) { _parentEntries.Push(e); foreach (var inner in e.InnerObjects) { DrawEntry(inner, indent + 12f); } _parentEntries.Pop(); } return(lineRect); }