forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestDataSource.cs
More file actions
51 lines (45 loc) · 1.23 KB
/
Copy pathTestDataSource.cs
File metadata and controls
51 lines (45 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using UnityEditor.IMGUI.Controls;
namespace UnityEditor.TreeViewExamples
{
internal class TestDataSource : TreeViewDataSource
{
private BackendData m_Backend;
public int itemCounter
{
get;
private set;
}
public TestDataSource(TreeViewController treeView, BackendData data) : base(treeView)
{
this.m_Backend = data;
this.FetchData();
}
public override void FetchData()
{
this.itemCounter = 1;
this.m_RootItem = new FooTreeViewItem(this.m_Backend.root.id, 0, null, this.m_Backend.root.name, this.m_Backend.root);
this.AddChildrenRecursive(this.m_Backend.root, this.m_RootItem);
this.m_NeedRefreshRows = true;
}
private void AddChildrenRecursive(BackendData.Foo source, TreeViewItem dest)
{
if (source.hasChildren)
{
dest.children = new List<TreeViewItem>(source.children.Count);
for (int i = 0; i < source.children.Count; i++)
{
BackendData.Foo foo = source.children[i];
dest.children.Add(new FooTreeViewItem(foo.id, dest.depth + 1, dest, foo.name, foo));
this.itemCounter++;
this.AddChildrenRecursive(foo, dest.children[i]);
}
}
}
public override bool CanBeParent(TreeViewItem item)
{
return true;
}
}
}