@@ -27,6 +27,7 @@ GUIStyle wrapStyle
27
27
}
28
28
float updateDelay = 1f ;
29
29
int captureCount = 100 ;
30
+ TickEvent eventHover = null ;
30
31
float showMax = 0 ;
31
32
float showMin = 0 ;
32
33
bool record = false ;
@@ -37,7 +38,6 @@ struct ProfilerContainer
37
38
{
38
39
public ProfilerTick [ ] ticks ;
39
40
}
40
-
41
41
private void OnGUI ( )
42
42
{
43
43
if ( ! NetworkProfiler . IsRunning && record )
@@ -212,14 +212,20 @@ record = EditorGUILayout.Toggle("Record", record);
212
212
{
213
213
TickEvent tickEvent = tick . Events [ j ] ;
214
214
Rect dataRect = new Rect ( currentX , currentY , widthPerTick , heightPerEvent ) ;
215
+
216
+ if ( dataRect . Contains ( Event . current . mousePosition ) ) eventHover = tickEvent ;
217
+ else if ( eventHover == tickEvent ) eventHover = null ;
218
+
215
219
if ( j == tick . Events . Count - 1 )
216
220
dataRect . height -= 45f ;
217
221
EditorGUI . DrawRect ( dataRect , TickTypeToColor ( tickEvent . EventType ) ) ;
218
222
float heightPerField = heightPerEvent / 12f ;
219
223
EditorGUI . LabelField ( new Rect ( dataRect . x , dataRect . y + heightPerField * - 3f , dataRect . width , dataRect . height ) , "EventType: " + tickEvent . EventType . ToString ( ) , wrapStyle ) ;
220
224
EditorGUI . LabelField ( new Rect ( dataRect . x , dataRect . y + heightPerField * - 1f , dataRect . width , dataRect . height ) , "Size: " + tickEvent . Bytes + "B" , wrapStyle ) ;
221
- EditorGUI . LabelField ( new Rect ( dataRect . x , dataRect . y + heightPerField * 1f , dataRect . width , dataRect . height ) , "Channel: " + tickEvent . ChannelName , wrapStyle ) ;
222
- EditorGUI . LabelField ( new Rect ( dataRect . x , dataRect . y + heightPerField * 3f , dataRect . width , dataRect . height ) , "MessageType: " + tickEvent . MessageType , wrapStyle ) ;
225
+ string channelName = tickEvent . ChannelName . Length > 5 ? tickEvent . ChannelName . Remove ( 5 , tickEvent . ChannelName . Length - 5 ) + "..." : tickEvent . ChannelName ;
226
+ EditorGUI . LabelField ( new Rect ( dataRect . x , dataRect . y + heightPerField * 1f , dataRect . width , dataRect . height ) , "Channel: " + channelName , wrapStyle ) ;
227
+ string messageType = tickEvent . MessageType . Length > 5 ? tickEvent . MessageType . Remove ( 5 , tickEvent . MessageType . Length - 5 ) + "..." : tickEvent . MessageType ;
228
+ EditorGUI . LabelField ( new Rect ( dataRect . x , dataRect . y + heightPerField * 3f , dataRect . width , dataRect . height ) , "MessageType: " + messageType , wrapStyle ) ;
223
229
224
230
currentY += heightPerEvent + 5f ;
225
231
}
@@ -230,10 +236,23 @@ record = EditorGUILayout.Toggle("Record", record);
230
236
currentX += widthPerTick ;
231
237
}
232
238
239
+ //Draw hover thingy
240
+ if ( eventHover != null )
241
+ {
242
+ Rect rect = new Rect ( Event . current . mousePosition , new Vector2 ( 500 , 100 ) ) ;
243
+ EditorGUI . DrawRect ( rect , EditorColor ) ;
244
+
245
+ float heightPerField = ( rect . height - 5 ) / 4 ;
246
+ EditorGUI . LabelField ( new Rect ( rect . x + 5 , rect . y + 5 , rect . width , rect . height ) , "EventType: " + eventHover . EventType . ToString ( ) ) ;
247
+ EditorGUI . LabelField ( new Rect ( rect . x + 5 , rect . y + heightPerField * 1 + 5 , rect . width , rect . height ) , "Size: " + eventHover . Bytes + "B" ) ;
248
+ EditorGUI . LabelField ( new Rect ( rect . x + 5 , rect . y + heightPerField * 2 + 5 , rect . width , rect . height ) , "Channel: " + eventHover . ChannelName ) ;
249
+ EditorGUI . LabelField ( new Rect ( rect . x + 5 , rect . y + heightPerField * 3 + 5 , rect . width , rect . height ) , "MessageType: " + eventHover . MessageType ) ;
250
+ }
251
+
233
252
Repaint ( ) ;
234
253
}
235
254
236
- private static Color TickTypeToColor ( TickType type )
255
+ private Color TickTypeToColor ( TickType type )
237
256
{
238
257
switch ( type )
239
258
{
@@ -243,8 +262,18 @@ private static Color TickTypeToColor(TickType type)
243
262
return new Color ( 0f , 0.85f , 0.85f , 0.28f ) ;
244
263
case TickType . Send :
245
264
return new Color ( 0 , 0.55f , 1f , 0.06f ) ;
265
+ default :
266
+ return Color . clear ;
267
+ }
268
+ }
269
+
270
+ private Color EditorColor
271
+ {
272
+ get
273
+ {
274
+ return EditorGUIUtility . isProSkin ? new Color32 ( 56 , 56 , 56 , 255 ) : new Color32 ( 194 , 194 , 194 , 255 ) ;
246
275
}
247
- return EditorGUIUtility . isProSkin ? new Color32 ( 70 , 70 , 70 , 255 ) : new Color32 ( 200 , 200 , 200 , 255 ) ;
248
276
}
249
277
}
278
+
250
279
}
0 commit comments