|
8 | 8 |
|
9 | 9 | namespace GitHub.Unity
|
10 | 10 | {
|
11 |
| - [Serializable] |
12 |
| - public class BranchesTree: Tree |
13 |
| - { |
14 |
| - [NonSerialized] public Texture2D ActiveNodeIcon; |
15 |
| - [NonSerialized] public Texture2D NodeIcon; |
16 |
| - [NonSerialized] public Texture2D FolderIcon; |
17 |
| - [NonSerialized] public Texture2D RootFolderIcon; |
18 |
| - |
19 |
| - protected override Texture2D GetNodeIcon(TreeNode node) |
20 |
| - { |
21 |
| - Texture2D nodeIcon; |
22 |
| - if (node.IsActive) |
23 |
| - { |
24 |
| - nodeIcon = ActiveNodeIcon; |
25 |
| - } |
26 |
| - else if (node.IsFolder) |
27 |
| - { |
28 |
| - if (node.Level == 1) |
29 |
| - nodeIcon = RootFolderIcon; |
30 |
| - else |
31 |
| - nodeIcon = FolderIcon; |
32 |
| - } |
33 |
| - else |
34 |
| - { |
35 |
| - nodeIcon = NodeIcon; |
36 |
| - } |
37 |
| - return nodeIcon; |
38 |
| - } |
39 |
| - |
40 |
| - public void UpdateIcons(Texture2D activeBranchIcon, Texture2D branchIcon, Texture2D folderIcon, Texture2D rootFolderIcon) |
41 |
| - { |
42 |
| - var localsLoaded = false; |
43 |
| - |
44 |
| - if (ActiveNodeIcon == null) |
45 |
| - { |
46 |
| - localsLoaded = true; |
47 |
| - ActiveNodeIcon = activeBranchIcon; |
48 |
| - } |
49 |
| - |
50 |
| - if (NodeIcon == null) |
51 |
| - { |
52 |
| - localsLoaded = true; |
53 |
| - NodeIcon = branchIcon; |
54 |
| - } |
55 |
| - |
56 |
| - if (FolderIcon == null) |
57 |
| - { |
58 |
| - localsLoaded = true; |
59 |
| - FolderIcon = folderIcon; |
60 |
| - } |
61 |
| - |
62 |
| - if (RootFolderIcon == null) |
63 |
| - { |
64 |
| - localsLoaded = true; |
65 |
| - RootFolderIcon = rootFolderIcon; |
66 |
| - } |
67 |
| - |
68 |
| - if (localsLoaded) |
69 |
| - { |
70 |
| - LoadNodeIcons(); |
71 |
| - } |
72 |
| - } |
73 |
| - } |
74 |
| - |
75 | 11 | [Serializable]
|
76 | 12 | public abstract class Tree
|
77 | 13 | {
|
@@ -513,4 +449,68 @@ public override string ToString()
|
513 | 449 | Name, Label, Level, IsFolder, IsCollapsed, IsHidden, IsActive);
|
514 | 450 | }
|
515 | 451 | }
|
| 452 | + |
| 453 | + [Serializable] |
| 454 | + public class BranchesTree: Tree |
| 455 | + { |
| 456 | + [NonSerialized] public Texture2D ActiveNodeIcon; |
| 457 | + [NonSerialized] public Texture2D NodeIcon; |
| 458 | + [NonSerialized] public Texture2D FolderIcon; |
| 459 | + [NonSerialized] public Texture2D RootFolderIcon; |
| 460 | + |
| 461 | + protected override Texture2D GetNodeIcon(TreeNode node) |
| 462 | + { |
| 463 | + Texture2D nodeIcon; |
| 464 | + if (node.IsActive) |
| 465 | + { |
| 466 | + nodeIcon = ActiveNodeIcon; |
| 467 | + } |
| 468 | + else if (node.IsFolder) |
| 469 | + { |
| 470 | + if (node.Level == 1) |
| 471 | + nodeIcon = RootFolderIcon; |
| 472 | + else |
| 473 | + nodeIcon = FolderIcon; |
| 474 | + } |
| 475 | + else |
| 476 | + { |
| 477 | + nodeIcon = NodeIcon; |
| 478 | + } |
| 479 | + return nodeIcon; |
| 480 | + } |
| 481 | + |
| 482 | + public void UpdateIcons(Texture2D activeBranchIcon, Texture2D branchIcon, Texture2D folderIcon, Texture2D rootFolderIcon) |
| 483 | + { |
| 484 | + var localsLoaded = false; |
| 485 | + |
| 486 | + if (ActiveNodeIcon == null) |
| 487 | + { |
| 488 | + localsLoaded = true; |
| 489 | + ActiveNodeIcon = activeBranchIcon; |
| 490 | + } |
| 491 | + |
| 492 | + if (NodeIcon == null) |
| 493 | + { |
| 494 | + localsLoaded = true; |
| 495 | + NodeIcon = branchIcon; |
| 496 | + } |
| 497 | + |
| 498 | + if (FolderIcon == null) |
| 499 | + { |
| 500 | + localsLoaded = true; |
| 501 | + FolderIcon = folderIcon; |
| 502 | + } |
| 503 | + |
| 504 | + if (RootFolderIcon == null) |
| 505 | + { |
| 506 | + localsLoaded = true; |
| 507 | + RootFolderIcon = rootFolderIcon; |
| 508 | + } |
| 509 | + |
| 510 | + if (localsLoaded) |
| 511 | + { |
| 512 | + LoadNodeIcons(); |
| 513 | + } |
| 514 | + } |
| 515 | + } |
516 | 516 | }
|
0 commit comments