@@ -17,70 +17,17 @@ public abstract class Tree<TNode, TData>: TreeBase<TNode, TData>
1717 public static float ItemHeight { get { return EditorGUIUtility . singleLineHeight ; } }
1818 public static float ItemSpacing { get { return EditorGUIUtility . standardVerticalSpacing ; } }
1919
20- [ SerializeField ] public Rect Margin = new Rect ( ) ;
21- [ SerializeField ] public Rect Padding = new Rect ( ) ;
22-
23- [ SerializeField ] public string title = string . Empty ;
24- [ SerializeField ] public string pathSeparator = "/" ;
25- [ SerializeField ] public bool displayRootNode = true ;
26- [ SerializeField ] public bool isCheckable = false ;
2720 [ NonSerialized ] public GUIStyle FolderStyle ;
2821 [ NonSerialized ] public GUIStyle TreeNodeStyle ;
2922 [ NonSerialized ] public GUIStyle ActiveTreeNodeStyle ;
3023
31- [ SerializeField ] private List < TNode > nodes = new List < TNode > ( ) ;
32- [ SerializeField ] private TNode selectedNode = null ;
33-
3424 [ NonSerialized ] private Stack < bool > indents = new Stack < bool > ( ) ;
3525 [ NonSerialized ] private Action < TNode > rightClickNextRender ;
3626 [ NonSerialized ] private TNode rightClickNextRenderNode ;
3727
3828 public bool IsInitialized { get { return Nodes != null && Nodes . Count > 0 && ! String . IsNullOrEmpty ( Nodes [ 0 ] . Path ) ; } }
3929 public bool RequiresRepaint { get ; private set ; }
4030
41- public override TNode SelectedNode
42- {
43- get
44- {
45- if ( selectedNode != null && String . IsNullOrEmpty ( selectedNode . Path ) )
46- selectedNode = null ;
47- return selectedNode ;
48- }
49- set
50- {
51- selectedNode = value ;
52- }
53- }
54-
55- public override string Title
56- {
57- get { return title ; }
58- set { title = value ; }
59- }
60-
61- public override bool DisplayRootNode
62- {
63- get { return displayRootNode ; }
64- set { displayRootNode = value ; }
65- }
66-
67- public override bool IsCheckable
68- {
69- get { return isCheckable ; }
70- set { isCheckable = value ; }
71- }
72-
73- public override string PathSeparator
74- {
75- get { return pathSeparator ; }
76- set { pathSeparator = value ; }
77- }
78-
79- protected override List < TNode > Nodes
80- {
81- get { return nodes ; }
82- }
83-
8431 public Rect Render ( Rect containingRect , Rect rect , Vector2 scroll , Action < TNode > singleClick = null , Action < TNode > doubleClick = null , Action < TNode > rightClick = null )
8532 {
8633 if ( Event . current . type != EventType . Repaint )
@@ -109,7 +56,7 @@ public Rect Render(Rect containingRect, Rect rect, Vector2 scroll, Action<TNode>
10956 var titleDisplay = ! ( rect . y > endDisplay || rect . yMax < startDisplay ) ;
11057 if ( titleDisplay )
11158 {
112- renderResult = titleNode . Render ( rect , Styles . TreeIndentation , selectedNode == titleNode , FolderStyle , TreeNodeStyle , ActiveTreeNodeStyle ) ;
59+ renderResult = titleNode . Render ( rect , Styles . TreeIndentation , SelectedNode == titleNode , FolderStyle , TreeNodeStyle , ActiveTreeNodeStyle ) ;
11360 }
11461
11562 if ( renderResult == TreeNodeRenderResult . VisibilityChange )
@@ -142,7 +89,7 @@ public Rect Render(Rect containingRect, Rect rect, Vector2 scroll, Action<TNode>
14289 var display = ! ( rect . y > endDisplay || rect . yMax < startDisplay ) ;
14390 if ( display )
14491 {
145- renderResult = node . Render ( rect , Styles . TreeIndentation , selectedNode == node , FolderStyle , TreeNodeStyle , ActiveTreeNodeStyle ) ;
92+ renderResult = node . Render ( rect , Styles . TreeIndentation , SelectedNode == node , FolderStyle , TreeNodeStyle , ActiveTreeNodeStyle ) ;
14693 }
14794
14895 if ( renderResult == TreeNodeRenderResult . VisibilityChange )
@@ -234,7 +181,7 @@ private bool HandleInput(Rect rect, TNode currentNode, int index, Action<TNode>
234181 }
235182
236183 // Keyboard navigation if this child is the current selection
237- if ( currentNode == selectedNode && Event . current . type == EventType . KeyDown )
184+ if ( currentNode == SelectedNode && Event . current . type == EventType . KeyDown )
238185 {
239186 int directionY = Event . current . keyCode == KeyCode . UpArrow ? - 1 : Event . current . keyCode == KeyCode . DownArrow ? 1 : 0 ;
240187 int directionX = Event . current . keyCode == KeyCode . LeftArrow ? - 1 : Event . current . keyCode == KeyCode . RightArrow ? 1 : 0 ;
@@ -541,6 +488,56 @@ public class BranchesTree : Tree<TreeNode, GitBranchTreeData>
541488 [ NonSerialized ] public Texture2D BranchIcon ;
542489 [ NonSerialized ] public Texture2D FolderIcon ;
543490 [ NonSerialized ] public Texture2D GlobeIcon ;
491+ [ SerializeField ] public string title = string . Empty ;
492+ [ SerializeField ] public string pathSeparator = "/" ;
493+ [ SerializeField ] public bool displayRootNode = true ;
494+ [ SerializeField ] public bool isCheckable = false ;
495+ [ SerializeField ] private List < TreeNode > nodes = new List < TreeNode > ( ) ;
496+ [ SerializeField ] private TreeNode selectedNode = null ;
497+
498+ public override string Title
499+ {
500+ get { return title ; }
501+ set { title = value ; }
502+ }
503+
504+ public override bool DisplayRootNode
505+ {
506+ get { return displayRootNode ; }
507+ set { displayRootNode = value ; }
508+ }
509+
510+ public override bool IsCheckable
511+ {
512+ get { return isCheckable ; }
513+ set { isCheckable = value ; }
514+ }
515+
516+ public override string PathSeparator
517+ {
518+ get { return pathSeparator ; }
519+ set { pathSeparator = value ; }
520+ }
521+
522+ public override TreeNode SelectedNode
523+ {
524+ get
525+ {
526+ if ( selectedNode != null && String . IsNullOrEmpty ( selectedNode . Path ) )
527+ selectedNode = null ;
528+
529+ return selectedNode ;
530+ }
531+ set
532+ {
533+ selectedNode = value ;
534+ }
535+ }
536+
537+ protected override List < TreeNode > Nodes
538+ {
539+ get { return nodes ; }
540+ }
544541
545542 public void UpdateIcons ( Texture2D activeBranchIcon , Texture2D branchIcon , Texture2D folderIcon , Texture2D globeIcon )
546543 {
0 commit comments