@@ -38,7 +38,6 @@ public static string DurationToString(this Playable playable, string format = "F
3838 return durationStr ;
3939 }
4040
41-
4241 public static void SetNodeStyle ( this GraphViewNode node , Color nodeColor ,
4342 float titleFontSize = 15 , Color ? titleColor = null )
4443 {
@@ -51,10 +50,22 @@ public static void SetNodeStyle(this GraphViewNode node, Color nodeColor,
5150 }
5251
5352
53+ #region Port Color
54+
5455 // Ensure edge is always visible.
5556 public const float ColorAlphaFactor = 1f / 9 ;
5657
5758
59+ public static Color GetPortColor ( float weight )
60+ {
61+ var alpha = ( weight + ColorAlphaFactor ) / ( 1 + ColorAlphaFactor ) ;
62+ return new Color ( 1 , 1 , 1 , alpha ) ;
63+ }
64+
65+ #endregion
66+
67+
68+
5869 public static Color GetButtonBackgroundColor ( bool isChecked )
5970 {
6071 if ( isChecked )
@@ -77,24 +88,22 @@ public static Color GetNodeInspectorBackgroundColor()
7788 new Color32 ( 175 , 175 , 175 , 255 ) ; // light
7889 }
7990
91+
92+ #region Node Color
93+
8094 public static Color GetNodeInspectorTextColor ( )
8195 {
8296 return EditorGUIUtility . isProSkin ?
8397 new Color32 ( 255 , 255 , 255 , 255 ) : // dark
8498 new Color32 ( 0 , 0 , 0 , 255 ) ; // light
8599 }
86100
87- public static Color GetPortColor ( float weight )
88- {
89- var alpha = ( weight + ColorAlphaFactor ) / ( 1 + ColorAlphaFactor ) ;
90- return new Color ( 1 , 1 , 1 , alpha ) ;
91- }
92-
93101 public static Color GetNodeInvalidColor ( )
94102 {
95103 return Color . red ;
96104 }
97105
106+ // (0, ?, 255, 255) for PlayableOutput nodes
98107 public static Color GetPlayableOutputNodeColor ( this ref PlayableOutput playableOutput )
99108 {
100109 if ( playableOutput . IsPlayableOutputOfType < AnimationPlayableOutput > ( ) )
@@ -111,40 +120,37 @@ public static Color GetPlayableOutputNodeColor(this ref PlayableOutput playableO
111120 return GetRandomColorForType ( playableOutput . GetPlayableOutputType ( ) ) ;
112121 }
113122
123+ // (0, 255, ?, 255) for Playable nodes
114124 public static Color GetPlayableNodeColor ( this ref Playable playable )
115125 {
116126 if ( playable . IsPlayableOfType < AnimationClipPlayable > ( ) )
117127 {
118- return new Color32 ( 0 , 255 , 102 , 255 ) ;
128+ return new Color32 ( 0 , 255 , 51 , 255 ) ;
119129 }
120130
121131 if ( playable . IsPlayableOfType < AnimationMixerPlayable > ( ) )
122132 {
123- return new Color32 ( 0 , 255 , 153 , 255 ) ;
133+ return new Color32 ( 0 , 255 , 102 , 255 ) ;
124134 }
125135
126136 if ( playable . IsPlayableOfType < AnimationLayerMixerPlayable > ( ) )
127137 {
128- return new Color32 ( 0 , 255 , 204 , 255 ) ;
138+ return new Color32 ( 0 , 255 , 153 , 255 ) ;
129139 }
130140
131- return GetRandomColorForType ( playable . GetPlayableType ( ) ) ;
132- }
133-
134- public static Color GetRandomColorForType ( this Type type )
135- {
136- if ( _colorCache . TryGetValue ( type , out var color ) )
141+ if ( playable . IsPlayableOfType < AnimationScriptPlayable > ( ) )
137142 {
138- return color ;
143+ return new Color32 ( 0 , 255 , 204 , 255 ) ;
139144 }
140145
141- color = ColorPool [ URandom . Range ( 0 , ColorPool . Count ) ] ;
142- _colorCache [ type ] = color ;
143-
144- return color ;
146+ return GetRandomColorForType ( playable . GetPlayableType ( ) ) ;
145147 }
146148
149+ #endregion
150+
147151
152+ // reserve (0, ?, 255, 255) for PlayableOutput nodes
153+ // reserve (0, 255, ?, 255) for Playable nodes
148154 public static readonly IReadOnlyList < Color32 > ColorPool = new Color32 [ ]
149155 {
150156 new Color32 ( 255 , 0 , 255 , 255 ) , new Color32 ( 255 , 0 , 153 , 255 ) ,
@@ -159,6 +165,19 @@ public static Color GetRandomColorForType(this Type type)
159165 private static readonly Dictionary < Type , Color32 > _colorCache = new Dictionary < Type , Color32 > ( ) ;
160166
161167
168+ public static Color GetRandomColorForType ( this Type type )
169+ {
170+ if ( _colorCache . TryGetValue ( type , out var color ) )
171+ {
172+ return color ;
173+ }
174+
175+ color = ColorPool [ URandom . Range ( 0 , ColorPool . Count ) ] ;
176+ _colorCache [ type ] = color ;
177+
178+ return color ;
179+ }
180+
162181 public static void ClearGlobalCache ( )
163182 {
164183 _colorCache . Clear ( ) ;
0 commit comments