@@ -251,41 +251,24 @@ public virtual void Apply(MaterialProperty prop)
251251 // syntax in shaders, e.g. [Toggle] in front of a shader property will
252252 // end up using MaterialToggleDrawer to display it as a toggle.
253253
254-
255- internal class MaterialToggleDrawer : MaterialPropertyDrawer
254+ // Variant of the ToggleDrawer that defines no keyword (just UI)
255+ internal class MaterialToggleUIDrawer : MaterialPropertyDrawer
256256 {
257- protected readonly string keyword ;
258- public MaterialToggleDrawer ( )
259- {
260- }
261-
262- public MaterialToggleDrawer ( string keyword )
257+ public MaterialToggleUIDrawer ( )
263258 {
264- this . keyword = keyword ;
265259 }
266260
267- static bool IsPropertyTypeSuitable ( MaterialProperty prop )
261+ public MaterialToggleUIDrawer ( string keyword )
268262 {
269- return prop . type == MaterialProperty . PropType . Float || prop . type == MaterialProperty . PropType . Range ;
270263 }
271264
272265 protected virtual void SetKeyword ( MaterialProperty prop , bool on )
273266 {
274- SetKeywordInternal ( prop , on , "_ON" ) ;
275267 }
276268
277- protected void SetKeywordInternal ( MaterialProperty prop , bool on , string defaultKeywordSuffix )
269+ static bool IsPropertyTypeSuitable ( MaterialProperty prop )
278270 {
279- // if no keyword is provided, use <uppercase property name> + defaultKeywordSuffix
280- string kw = string . IsNullOrEmpty ( keyword ) ? prop . name . ToUpperInvariant ( ) + defaultKeywordSuffix : keyword ;
281- // set or clear the keyword
282- foreach ( Material material in prop . targets )
283- {
284- if ( on )
285- material . EnableKeyword ( kw ) ;
286- else
287- material . DisableKeyword ( kw ) ;
288- }
271+ return prop . type == MaterialProperty . PropType . Float || prop . type == MaterialProperty . PropType . Range ;
289272 }
290273
291274 public override float GetPropertyHeight ( MaterialProperty prop , string label , MaterialEditor editor )
@@ -333,6 +316,39 @@ public override void Apply(MaterialProperty prop)
333316 }
334317 }
335318
319+
320+ internal class MaterialToggleDrawer : MaterialToggleUIDrawer
321+ {
322+ protected readonly string keyword ;
323+ public MaterialToggleDrawer ( )
324+ {
325+ }
326+
327+ public MaterialToggleDrawer ( string keyword )
328+ {
329+ this . keyword = keyword ;
330+ }
331+
332+ protected override void SetKeyword ( MaterialProperty prop , bool on )
333+ {
334+ SetKeywordInternal ( prop , on , "_ON" ) ;
335+ }
336+
337+ protected void SetKeywordInternal ( MaterialProperty prop , bool on , string defaultKeywordSuffix )
338+ {
339+ // if no keyword is provided, use <uppercase property name> + defaultKeywordSuffix
340+ string kw = string . IsNullOrEmpty ( keyword ) ? prop . name . ToUpperInvariant ( ) + defaultKeywordSuffix : keyword ;
341+ // set or clear the keyword
342+ foreach ( Material material in prop . targets )
343+ {
344+ if ( on )
345+ material . EnableKeyword ( kw ) ;
346+ else
347+ material . DisableKeyword ( kw ) ;
348+ }
349+ }
350+ }
351+
336352 // Variant of the ToggleDrawer that defines a keyword when it's not on
337353 // This is useful when adding Toggles to existing shaders while maintaining backwards compatibility
338354 internal class MaterialToggleOffDrawer : MaterialToggleDrawer
0 commit comments