@@ -129,7 +129,7 @@ public partial class MaterialEditorPluginBase : BaseUnityPlugin
129
129
/// When enabled, normalmaps get converted from DXT5 compressed (red) normals back to normal OpenGL (blue/purple) normals
130
130
/// </summary>
131
131
public static ConfigEntry < bool > ConvertNormalmapsOnExport { get ; set ; }
132
-
132
+
133
133
/// <summary>
134
134
/// Init logic, do not call
135
135
/// </summary>
@@ -259,11 +259,12 @@ private static void LoadXML()
259
259
ShaderPropertyType propertyType = ( ShaderPropertyType ) Enum . Parse ( typeof ( ShaderPropertyType ) , shaderPropertyElement . GetAttribute ( "Type" ) ) ;
260
260
string defaultValue = shaderPropertyElement . GetAttribute ( "DefaultValue" ) ;
261
261
string defaultValueAB = shaderPropertyElement . GetAttribute ( "DefaultValueAssetBundle" ) ;
262
- string hidden = shaderPropertyElement . GetAttribute ( "Hidden" ) ;
262
+ string anisoLevel = shaderPropertyElement . GetAttribute ( "AnisoLevel" ) ;
263
+ string filterMode = shaderPropertyElement . GetAttribute ( "FilterMode" ) ;
264
+ string wrapMode = shaderPropertyElement . GetAttribute ( "WrapMode" ) ;
263
265
string range = shaderPropertyElement . GetAttribute ( "Range" ) ;
264
266
string min = null ;
265
267
string max = null ;
266
- string category = shaderPropertyElement . GetAttribute ( "Category" ) ;
267
268
if ( ! range . IsNullOrWhiteSpace ( ) )
268
269
{
269
270
var rangeSplit = range . Split ( ',' ) ;
@@ -273,7 +274,16 @@ private static void LoadXML()
273
274
max = rangeSplit [ 1 ] ;
274
275
}
275
276
}
276
- ShaderPropertyData shaderPropertyData = new ShaderPropertyData ( propertyName , propertyType , defaultValue , defaultValueAB , hidden , min , max , category ) ;
277
+ string hidden = shaderPropertyElement . GetAttribute ( "Hidden" ) ;
278
+ string category = shaderPropertyElement . GetAttribute ( "Category" ) ;
279
+
280
+ ShaderPropertyData shaderPropertyData = new ShaderPropertyData (
281
+ propertyName , propertyType ,
282
+ defaultValue , defaultValueAB ,
283
+ anisoLevel , filterMode , wrapMode ,
284
+ min , max ,
285
+ hidden , category
286
+ ) ;
277
287
278
288
XMLShaderProperties [ "default" ] [ propertyName ] = shaderPropertyData ;
279
289
}
@@ -417,22 +427,34 @@ public class ShaderPropertyData
417
427
/// </summary>
418
428
public string DefaultValue ;
419
429
/// <summary>
420
- /// Default value of the shader property when loaded from an asset bundle.
430
+ /// Default value of the shader property when loaded from an asset bundle, like a texture .
421
431
/// </summary>
422
432
public string DefaultValueAssetBundle ;
423
433
/// <summary>
424
- /// Indicates whether the shader property is hidden .
434
+ /// Should only be used with texture properties. The `anisoLevel` of the texture, 0-16 .
425
435
/// </summary>
426
- public bool Hidden ;
436
+ public int ? AnisoLevel ;
427
437
/// <summary>
428
- /// Minimum value of the shader property, if applicable.
438
+ /// Should only be used with texture properties. The `filterMode` of the texture.
439
+ /// </summary>
440
+ public FilterMode ? FilterMode ;
441
+ /// <summary>
442
+ /// Should only be used with texture properties. The `wrapMode` of the texture.
443
+ /// </summary>
444
+ public TextureWrapMode ? WrapMode ;
445
+ /// <summary>
446
+ /// Should only be used with float properties. Minimum value displayed on the slider, if applicable.
429
447
/// </summary>
430
448
public float ? MinValue ;
431
449
/// <summary>
432
- /// Maximum value of the shader property , if applicable.
450
+ /// Should only be used with float properties. Maximum value displayed on the slider , if applicable.
433
451
/// </summary>
434
452
public float ? MaxValue ;
435
453
/// <summary>
454
+ /// Indicates whether the shader property is hidden.
455
+ /// </summary>
456
+ public bool Hidden ;
457
+ /// <summary>
436
458
/// Category of the shader property.
437
459
/// </summary>
438
460
public string Category ;
@@ -443,18 +465,45 @@ public class ShaderPropertyData
443
465
/// <param name="name">Name of the shader property.</param>
444
466
/// <param name="type">Type of the shader property.</param>
445
467
/// <param name="defaultValue">Default value of the shader property.</param>
446
- /// <param name="defaultValueAB">Default value of the shader property when loaded from an asset bundle.</param>
468
+ /// <param name="defaultValueAB">Default value of the shader property when loaded from an asset bundle, like a texture.</param>
469
+ /// <param name="anisoLevel">Should only be used with texture properties. The `anisoLevel` of the texture, 0-16.</param>
470
+ /// <param name="filterMode">Should only be used with texture properties. The `filterMode` of the texture.</param>
471
+ /// <param name="wrapMode">Should only be used with texture properties. The `wrapMode` of the texture.</param>
472
+ /// <param name="minValue">Should only be used with float properties. Minimum value displayed on the slider, if applicable.</param>
473
+ /// <param name="maxValue">Should only be used with float properties. Maximum value displayed on the slider, if applicable.</param>
447
474
/// <param name="hidden">Indicates whether the shader property is hidden.</param>
448
- /// <param name="minValue">Minimum value of the shader property.</param>
449
- /// <param name="maxValue">Maximum value of the shader property.</param>
450
475
/// <param name="category">Category of the shader property.</param>
451
- public ShaderPropertyData ( string name , ShaderPropertyType type , string defaultValue = null , string defaultValueAB = null , string hidden = null , string minValue = null , string maxValue = null , string category = null )
476
+ public ShaderPropertyData (
477
+ string name , ShaderPropertyType type ,
478
+ string defaultValue = null , string defaultValueAB = null ,
479
+ string anisoLevel = null , string filterMode = null , string wrapMode = null ,
480
+ string minValue = null , string maxValue = null ,
481
+ string hidden = null , string category = null
482
+ )
452
483
{
453
484
Name = name ;
454
485
Type = type ;
455
486
DefaultValue = defaultValue . IsNullOrEmpty ( ) ? null : defaultValue ;
456
487
DefaultValueAssetBundle = defaultValueAB . IsNullOrEmpty ( ) ? null : defaultValueAB ;
457
- Hidden = bool . TryParse ( hidden , out bool result ) && result ;
488
+
489
+ if ( ! anisoLevel . IsNullOrWhiteSpace ( ) )
490
+ {
491
+ int . TryParse ( anisoLevel , out int outAnisoLevel ) ;
492
+ AnisoLevel = Mathf . Clamp ( outAnisoLevel , 0 , 16 ) ;
493
+ }
494
+
495
+ if ( ! filterMode . IsNullOrWhiteSpace ( ) )
496
+ {
497
+ int . TryParse ( filterMode , out int outFilterMode ) ;
498
+ if ( Enum . IsDefined ( typeof ( FilterMode ) , outFilterMode ) ) FilterMode = ( FilterMode ) outFilterMode ;
499
+ }
500
+
501
+ if ( ! wrapMode . IsNullOrWhiteSpace ( ) )
502
+ {
503
+ int . TryParse ( wrapMode , out int outWrapMode ) ;
504
+ if ( Enum . IsDefined ( typeof ( TextureWrapMode ) , outWrapMode ) ) WrapMode = ( TextureWrapMode ) outWrapMode ;
505
+ }
506
+
458
507
if ( ! minValue . IsNullOrWhiteSpace ( ) && ! maxValue . IsNullOrWhiteSpace ( ) )
459
508
{
460
509
if ( float . TryParse ( minValue , out float min ) && float . TryParse ( maxValue , out float max ) )
@@ -463,6 +512,8 @@ public ShaderPropertyData(string name, ShaderPropertyType type, string defaultVa
463
512
MaxValue = max ;
464
513
}
465
514
}
515
+
516
+ Hidden = bool . TryParse ( hidden , out bool result ) && result ;
466
517
Category = category ;
467
518
}
468
519
}
0 commit comments