11using GBG . PlayableGraphMonitor . Editor . Node ;
22using System ;
33using System . Collections . Generic ;
4+ using UnityEditor ;
45using UnityEngine ;
56using UnityEngine . Animations ;
67using UnityEngine . Playables ;
@@ -29,6 +30,14 @@ public static bool IsEqual(ref PlayableGraph a, ref PlayableGraph b)
2930 return nameA . Equals ( nameB ) ;
3031 }
3132
33+ public static string DurationToString ( this Playable playable , string format = "F3" )
34+ {
35+ var duration = playable . GetDuration ( ) ;
36+ var durationStr = duration > float . MaxValue ? "+Inf" : duration . ToString ( format ) ;
37+
38+ return durationStr ;
39+ }
40+
3241
3342 public static void SetNodeStyle ( this GraphViewNode node , Color nodeColor ,
3443 float titleFontSize = 15 , Color ? titleColor = null )
@@ -46,6 +55,35 @@ public static void SetNodeStyle(this GraphViewNode node, Color nodeColor,
4655 public const float ColorAlphaFactor = 1f / 9 ;
4756
4857
58+ public static Color GetButtonBackgroundColor ( bool isChecked )
59+ {
60+ if ( isChecked )
61+ {
62+ return EditorGUIUtility . isProSkin ?
63+ new Color32 ( 70 , 96 , 124 , 255 ) : // dark
64+ new Color32 ( 150 , 195 , 251 , 255 ) ; // light
65+
66+ }
67+
68+ return EditorGUIUtility . isProSkin ?
69+ new Color32 ( 88 , 88 , 88 , 255 ) : // dark
70+ new Color32 ( 228 , 228 , 228 , 255 ) ; // light
71+ }
72+
73+ public static Color GetNodeInspectorBackgroundColor ( )
74+ {
75+ return EditorGUIUtility . isProSkin ?
76+ new Color32 ( 50 , 50 , 50 , 255 ) : // dark
77+ new Color32 ( 175 , 175 , 175 , 255 ) ; // light
78+ }
79+
80+ public static Color GetNodeInspectorTextColor ( )
81+ {
82+ return EditorGUIUtility . isProSkin ?
83+ new Color32 ( 255 , 255 , 255 , 255 ) : // dark
84+ new Color32 ( 0 , 0 , 0 , 255 ) ; // light
85+ }
86+
4987 public static Color GetPortColor ( float weight )
5088 {
5189 var alpha = ( weight + ColorAlphaFactor ) / ( 1 + ColorAlphaFactor ) ;
0 commit comments