static void DoCurveColorIndicator(Rect rect, CurveTreeViewNode node) { if (node == null) { return; } if (Event.current.type != EventType.Repaint) { return; } Color originalColor = GUI.color; if (node.bindings.Length == 1 && !node.bindings[0].isPPtrCurve) { GUI.color = CurveUtility.GetPropertyColor(node.bindings[0].propertyName); } else { GUI.color = s_KeyColorForNonCurves; } Texture icon = CurveUtility.GetIconCurve(); rect = new Rect(rect.xMax - k_RowRightOffset - (k_CurveColorIndicatorIconSize / 2) - 5, rect.yMin + k_ColorIndicatorTopMargin + (rect.height - EditorGUIUtility.singleLineHeight) / 2, k_CurveColorIndicatorIconSize, k_CurveColorIndicatorIconSize); GUI.DrawTexture(rect, icon, ScaleMode.ScaleToFit, true, 1); GUI.color = originalColor; }
public override void OnRowGUI(Rect rowRect, TreeViewItem node, int row, bool selected, bool focused) { Color originalColor = GUI.color; bool leafNode = node.parent != null && node.parent.id != BindingTreeViewDataSource.RootID && node.parent.id != BindingTreeViewDataSource.GroupID; GUI.color = Color.white; if (leafNode) { CurveTreeViewNode curveNode = node as CurveTreeViewNode; if (curveNode != null && curveNode.bindings.Any() && curveNode.bindings.First().isPhantom) { GUI.color = s_PhantomPropertyLabelColor; } else { GUI.color = s_ChildrenCurveLabelColor; } } base.OnRowGUI(rowRect, node, row, selected, focused); GUI.color = originalColor; DoCurveColorIndicator(rowRect, node as CurveTreeViewNode); }
public override void FetchData() { if (m_Clip == null) { return; } var bindings = AnimationUtility.GetCurveBindings(m_Clip) .Union(AnimationUtility.GetObjectReferenceCurveBindings(m_Clip)) .ToArray(); // a sorted linear list of nodes var results = bindings.GroupBy(GetBindingGroup, p => p, CreateTuple) .OrderBy(t => t.Item1.Path) .ThenBy(NamePrioritySort) // this makes component ordering match the animation window .ThenBy(t => t.Item1.Type.ToString()) .ThenBy(t => t.Item1.GroupName).ToArray(); m_RootItem = new CurveTreeViewNode(RootID, null, "root", null) { children = new List <TreeViewItem>(1) }; if (results.Any()) { var groupingNode = new CurveTreeViewNode(GroupID, m_RootItem, m_CurveDataSource.groupingName, bindings) { children = new List <TreeViewItem>() }; m_RootItem.children.Add(groupingNode); foreach (var r in results) { var key = r.Item1; var nodeBindings = r.Item2; FillMissingTransformCurves(nodeBindings); if (nodeBindings.Count == 1) { groupingNode.children.Add(CreateLeafNode(nodeBindings[0], groupingNode, PropertyName(nodeBindings[0], true))); } else if (nodeBindings.Count > 1) { var childBindings = nodeBindings.OrderBy(BindingSort).ToArray(); var parent = new CurveTreeViewNode(key.GetHashCode(), groupingNode, key.groupDisplayName, childBindings) { children = new List <TreeViewItem>() }; groupingNode.children.Add(parent); foreach (var b in childBindings) { parent.children.Add(CreateLeafNode(b, parent, PropertyName(b, false))); } } } SetupRootNodeSettings(); } m_NeedRefreshRows = true; }