Пример #1
0
        protected virtual Rect DoFoldout(Rect rowRect, TreeViewItem item, int row)
        {
            Rect position = new Rect(this.GetFoldoutIndent(item), rowRect.y, this.k_FoldoutWidth, rowRect.height);
            TreeViewItemExpansionAnimator expansionAnimator = this.m_TreeView.expansionAnimator;

            EditorGUI.BeginChangeCheck();
            bool expand;

            if (expansionAnimator.IsAnimating(item.id))
            {
                Matrix4x4 matrix = GUI.matrix;
                float     num    = Mathf.Min(1f, expansionAnimator.expandedValueNormalized * 2f);
                GUIUtility.RotateAroundPivot(expansionAnimator.isExpanding ? (float)((1.0 - (double)num) * -90.0) : num * 90f, position.center);
                bool isExpanding = expansionAnimator.isExpanding;
                expand     = GUI.Toggle(position, isExpanding, GUIContent.none, TreeViewGUI.s_Styles.foldout);
                GUI.matrix = matrix;
            }
            else
            {
                expand = GUI.Toggle(position, this.m_TreeView.data.IsExpanded(item), GUIContent.none, TreeViewGUI.s_Styles.foldout);
            }
            if (EditorGUI.EndChangeCheck())
            {
                this.m_TreeView.UserInputChangedExpandedState(item, row, expand);
            }
            return(position);
        }
Пример #2
0
        protected virtual Rect DoFoldout(Rect rowRect, TreeViewItem item, int row)
        {
            float foldoutIndent = this.GetFoldoutIndent(item);
            Rect  rect          = new Rect(foldoutIndent, rowRect.y, this.k_FoldoutWidth, rowRect.height);
            TreeViewItemExpansionAnimator expansionAnimator = this.m_TreeView.expansionAnimator;

            EditorGUI.BeginChangeCheck();
            bool expand;

            if (expansionAnimator.IsAnimating(item.id))
            {
                Matrix4x4 matrix = GUI.matrix;
                float     num    = Mathf.Min(1f, expansionAnimator.expandedValueNormalized * 2f);
                float     angle;
                if (!expansionAnimator.isExpanding)
                {
                    angle = num * 90f;
                }
                else
                {
                    angle = (1f - num) * -90f;
                }
                GUIUtility.RotateAroundPivot(angle, rect.center);
                bool isExpanding = expansionAnimator.isExpanding;
                expand     = GUI.Toggle(rect, isExpanding, GUIContent.none, TreeViewGUI.s_Styles.foldout);
                GUI.matrix = matrix;
            }
            else
            {
                expand = GUI.Toggle(rect, this.m_TreeView.data.IsExpanded(item), GUIContent.none, TreeViewGUI.s_Styles.foldout);
            }
            if (EditorGUI.EndChangeCheck())
            {
                this.m_TreeView.UserInputChangedExpandedState(item, row, expand);
            }
            return(rect);
        }