11using System . Linq ;
22using CleverCrow . Fluid . BTs . TaskParents ;
3+ using UnityEditor ;
34using UnityEngine ;
45
56namespace CleverCrow . Fluid . BTs . Trees . Editors {
@@ -16,20 +17,21 @@ public class NodePrintController {
1617 private Texture2D _verticalTop ;
1718
1819 private static GuiStyleCollection Styles => BehaviorTreePrinter . SharedStyles ;
20+ private static Color LineColor => EditorGUIUtility . isProSkin ? Color . white : Color . black ;
1921
2022 public NodePrintController ( VisualTask node ) {
2123 _node = node ;
2224 _box = node . Box ;
2325 _divider = node . Divider ;
2426 _iconMain = new TextureLoader ( _node . Task . IconPath ) ;
2527 }
26-
28+
2729 public void Print ( bool taskIsActive ) {
2830 if ( ! ( _node . Task is TaskRoot ) ) PaintVerticalTop ( ) ;
2931 _faders . Update ( taskIsActive ) ;
30-
32+
3133 PaintBody ( ) ;
32-
34+
3335 if ( _node . Children . Count > 0 ) {
3436 PaintDivider ( ) ;
3537 PaintVerticalBottom ( ) ;
@@ -38,23 +40,23 @@ public void Print (bool taskIsActive) {
3840
3941 private void PaintBody ( ) {
4042 var prevBackgroundColor = GUI . backgroundColor ;
41-
43+
4244 var rect = new Rect (
43- _box . GlobalPositionX + _box . PaddingX ,
45+ _box . GlobalPositionX + _box . PaddingX ,
4446 _box . GlobalPositionY + _box . PaddingY ,
45- _box . Width - _box . PaddingX ,
47+ _box . Width - _box . PaddingX ,
4648 _box . Height - _box . PaddingY ) ;
4749
4850 if ( _node . Task . HasBeenActive ) {
4951 GUI . backgroundColor = _faders . BackgroundFader . CurrentColor ;
5052 GUI . Box ( rect , GUIContent . none , Styles . BoxActive . Style ) ;
5153 GUI . backgroundColor = prevBackgroundColor ;
52-
54+
5355 PrintLastStatus ( rect ) ;
5456 } else {
5557 GUI . Box ( rect , GUIContent . none , Styles . BoxInactive . Style ) ;
5658 }
57-
59+
5860 PrintIcon ( ) ;
5961
6062 Styles . Title . normal . textColor = _faders . TextFader . CurrentColor ;
@@ -87,57 +89,57 @@ private void PrintIcon () {
8789
8890 private void PaintDivider ( ) {
8991 const int graphicSizeIncrease = 5 ;
90-
92+
9193 if ( _dividerGraphic == null ) {
9294 _dividerGraphic = CreateTexture (
93- ( int ) _divider . Width + graphicSizeIncrease ,
94- 1 ,
95- Color . black ) ;
95+ ( int ) _divider . Width + graphicSizeIncrease ,
96+ 1 ,
97+ LineColor ) ;
9698 }
9799
98100 var position = new Rect (
99- _divider . GlobalPositionX + _box . PaddingY / 2 + _node . DividerLeftOffset - 2 ,
100- // @TODO Should not need to offset this
101+ _divider . GlobalPositionX + _box . PaddingX / 2 + _node . DividerLeftOffset - 2 ,
101102 _divider . GlobalPositionY + _box . PaddingY / 2 ,
102- _divider . Width + graphicSizeIncrease ,
103- 10 ) ;
104-
103+ _divider . Width + graphicSizeIncrease ,
104+ // @NOTE I have no clue why 3 works here...
105+ 3 ) ;
106+
105107 GUI . Label ( position , _dividerGraphic ) ;
106108 }
107109
108110 private void PaintVerticalBottom ( ) {
109111 if ( _verticalBottom == null ) {
110- _verticalBottom = CreateTexture ( 1 , ( int ) _box . PaddingY , Color . black ) ;
112+ _verticalBottom = CreateTexture ( 1 , ( int ) _box . PaddingY , LineColor ) ;
111113 }
112114
113115 var position = new Rect (
114- _box . GlobalPositionX + _node . Width / 2 + _box . PaddingX - 2 ,
116+ _box . GlobalPositionX + _node . Width / 2 + _box . PaddingX - 2 ,
115117 _box . GlobalPositionY + _node . Height + _box . PaddingY - 1 ,
116- 100 ,
117- _box . PaddingY - 1 ) ;
118-
118+ 100 ,
119+ _box . PaddingY ) ;
120+
119121 GUI . Label ( position , _verticalBottom ) ;
120122 }
121-
123+
122124 private void PaintVerticalTop ( ) {
123125 if ( _verticalTop == null ) {
124- _verticalTop = CreateTexture ( 1 , Mathf . RoundToInt ( _box . PaddingY / 2 ) , Color . black ) ;
126+ _verticalTop = CreateTexture ( 1 , Mathf . RoundToInt ( _box . PaddingY / 2 ) , LineColor ) ;
125127 }
126128
127129 var position = new Rect (
128- _box . GlobalPositionX + _node . Width / 2 + _box . PaddingX - 2 ,
130+ _box . GlobalPositionX + _node . Width / 2 + _box . PaddingX - 2 ,
129131 _box . GlobalPositionY + _box . PaddingY / 2 ,
130- 100 ,
131- 10 ) ;
132-
132+ 100 ,
133+ _box . PaddingY / 2 ) ;
134+
133135 GUI . Label ( position , _verticalTop ) ;
134136 }
135-
137+
136138 private static Texture2D CreateTexture ( int width , int height , Color color ) {
137139 var texture = new Texture2D ( width , height , TextureFormat . ARGB32 , false ) ;
138140 texture . SetPixels ( Enumerable . Repeat ( color , width * height ) . ToArray ( ) ) ;
139141 texture . Apply ( ) ;
140-
142+
141143 return texture ;
142144 }
143145 }
0 commit comments