@@ -109,6 +109,8 @@ public void DrawLine(Pen pen, float x1, float y1, float x2, float y2, object mat
109109 var penWidth = pen . Width ;
110110
111111 if ( penColor . A <= 0 || penWidth <= 0 ) return ;
112+ if ( UE . Event . current . type != UE . EventType . repaint )
113+ return ;
112114
113115 var unityColor = penColor . ToUnityColor ( ) ;
114116
@@ -234,6 +236,8 @@ public void DrawRectangle(Pen pen, float x, float y, float width, float height,
234236 var penWidth = pen . Width ;
235237
236238 if ( penColor . A <= 0 || penWidth <= 0 ) return ;
239+ if ( UE . Event . current . type != UE . EventType . repaint )
240+ return ;
237241
238242 var color = penColor . ToUnityColor ( ) ;
239243 var penDash = pen . DashStyle ;
@@ -293,6 +297,9 @@ public void DrawString(string text, Font font, Color color, float x, float y, fl
293297 {
294298 if ( text == null || font == null ) return ;
295299
300+ if ( UE . Event . current . type != UE . EventType . repaint )
301+ return ;
302+
296303 // TODO: material not supported.
297304
298305 // Set align.
@@ -356,6 +363,9 @@ public void FillRectangle(Color color, float x, float y, float width, float heig
356363 if ( color . A <= 0 )
357364 return ;
358365
366+ if ( UE . Event . current . type != UE . EventType . repaint )
367+ return ;
368+
359369 var rect = new UE . Rect ( x , y , width , height ) ;
360370
361371 if ( material == null || material is UE . Material == false )
0 commit comments