@@ -302,29 +302,7 @@ private void BeginDecoratorDrawers(PropertyCondition conditionState = PropertyCo
302302
303303 for ( var i = 0 ; i < decoratorAttributes . Count ; i ++ )
304304 {
305- var attribute = decoratorAttributes [ i ] ;
306- var drawer = ToolboxDrawerModule . GetDecoratorDrawer ( attribute ) ;
307- if ( drawer == null )
308- {
309- continue ;
310- }
311-
312- if ( attribute . ApplyCondition )
313- {
314- var isValid = conditionState != PropertyCondition . NonValid ;
315- var disable = conditionState == PropertyCondition . Disabled ;
316- if ( isValid )
317- {
318- using ( new EditorGUI . DisabledScope ( disable ) )
319- {
320- drawer . OnGuiBegin ( attribute ) ;
321- }
322- }
323- }
324- else
325- {
326- drawer . OnGuiBegin ( attribute ) ;
327- }
305+ HandleDecorator ( decoratorAttributes [ i ] , true , conditionState ) ;
328306 }
329307 }
330308
@@ -337,7 +315,38 @@ private void CloseDecoratorDrawers(PropertyCondition conditionState = PropertyCo
337315
338316 for ( var i = decoratorAttributes . Count - 1 ; i >= 0 ; i -- )
339317 {
340- ToolboxDrawerModule . GetDecoratorDrawer ( decoratorAttributes [ i ] ) ? . OnGuiClose ( decoratorAttributes [ i ] ) ;
318+ HandleDecorator ( decoratorAttributes [ i ] , false , conditionState ) ;
319+ }
320+ }
321+
322+ private void HandleDecorator ( ToolboxDecoratorAttribute attribute , bool onBegin , PropertyCondition conditionState = PropertyCondition . Valid )
323+ {
324+ var drawer = ToolboxDrawerModule . GetDecoratorDrawer ( attribute ) ;
325+ if ( drawer == null )
326+ {
327+ return ;
328+ }
329+
330+ if ( ! attribute . ApplyCondition )
331+ {
332+ conditionState = PropertyCondition . Valid ;
333+ }
334+
335+ var isValid = conditionState != PropertyCondition . NonValid ;
336+ var disable = conditionState == PropertyCondition . Disabled ;
337+ if ( isValid )
338+ {
339+ using ( new EditorGUI . DisabledScope ( disable ) )
340+ {
341+ if ( onBegin )
342+ {
343+ drawer . OnGuiBegin ( attribute ) ;
344+ }
345+ else
346+ {
347+ drawer . OnGuiClose ( attribute ) ;
348+ }
349+ }
341350 }
342351 }
343352
0 commit comments