@@ -30,6 +30,8 @@ public abstract class Tree
30
30
[ SerializeField ] private TreeNodeDictionary folders = new TreeNodeDictionary ( ) ;
31
31
32
32
[ NonSerialized ] private Stack < bool > indents = new Stack < bool > ( ) ;
33
+ [ NonSerialized ] private Action < TreeNode > rightClickNextRender ;
34
+ [ NonSerialized ] private TreeNode rightClickNextRenderNode ;
33
35
34
36
public bool IsInitialized { get { return nodes != null && nodes . Count > 0 && ! String . IsNullOrEmpty ( nodes [ 0 ] . Name ) ; } }
35
37
public bool RequiresRepaint { get ; private set ; }
@@ -134,6 +136,16 @@ public void Load(IEnumerable<ITreeData> data, string title)
134
136
135
137
public Rect Render ( Rect rect , Vector2 scroll , Action < TreeNode > singleClick = null , Action < TreeNode > doubleClick = null , Action < TreeNode > rightClick = null )
136
138
{
139
+ if ( Event . current . type != EventType . Repaint )
140
+ {
141
+ if ( rightClickNextRender != null )
142
+ {
143
+ rightClickNextRender . Invoke ( rightClickNextRenderNode ) ;
144
+ rightClickNextRender = null ;
145
+ rightClickNextRenderNode = null ;
146
+ }
147
+ }
148
+
137
149
Profiler . BeginSample ( "TreeControl" ) ;
138
150
bool visible = true ;
139
151
var availableHeight = rect . y + rect . height ;
@@ -274,7 +286,8 @@ private bool HandleInput(Rect rect, TreeNode currentNode, int index, Action<Tree
274
286
}
275
287
if ( mouseButton == 1 && clickCount == 1 && rightClick != null )
276
288
{
277
- rightClick ( currentNode ) ;
289
+ rightClickNextRender = rightClick ;
290
+ rightClickNextRenderNode = currentNode ;
278
291
}
279
292
}
280
293
0 commit comments