@@ -293,7 +293,7 @@ private void DrawProperty(SerializedProperty property, GUIContent label)
293293 }
294294 }
295295
296- private void BeginDecoratorDrawers ( )
296+ private void BeginDecoratorDrawers ( PropertyCondition conditionState = PropertyCondition . Valid )
297297 {
298298 if ( ! hasToolboxDecoratorDrawer )
299299 {
@@ -302,11 +302,33 @@ private void BeginDecoratorDrawers()
302302
303303 for ( var i = 0 ; i < decoratorAttributes . Count ; i ++ )
304304 {
305- ToolboxDrawerModule . GetDecoratorDrawer ( decoratorAttributes [ i ] ) ? . OnGuiBegin ( decoratorAttributes [ i ] ) ;
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+ }
306328 }
307329 }
308330
309- private void CloseDecoratorDrawers ( )
331+ private void CloseDecoratorDrawers ( PropertyCondition conditionState = PropertyCondition . Valid )
310332 {
311333 if ( ! hasToolboxDecoratorDrawer )
312334 {
@@ -363,11 +385,10 @@ public void OnGuiLayout(SerializedProperty property, GUIContent label)
363385 //using custom attributes and information about native drawers
364386 //we can use all associated and allowed ToolboxDrawers (for each type)
365387
366- //begin all needed decorator drawers in the proper order
367- BeginDecoratorDrawers ( ) ;
368-
369388 //handle condition attribute and draw property if possible
370389 var conditionState = Validate ( property ) ;
390+ //begin all needed decorator drawers in the proper order
391+ BeginDecoratorDrawers ( conditionState ) ;
371392 var isValid = conditionState != PropertyCondition . NonValid ;
372393 var disable = conditionState == PropertyCondition . Disabled ;
373394 if ( isValid )
@@ -382,7 +403,7 @@ public void OnGuiLayout(SerializedProperty property, GUIContent label)
382403 }
383404
384405 //close all needed decorator drawers in the proper order
385- CloseDecoratorDrawers ( ) ;
406+ CloseDecoratorDrawers ( conditionState ) ;
386407 }
387408
388409 /// <summary>
0 commit comments