public class LowendMobilePipelineMaterialEditor : MaterialEditor
{
private MaterialProperty blendMode = null ;
private MaterialProperty albedoMap = null ;
private MaterialProperty albedoColor = null ;
private MaterialProperty alphaCutoff = null ;
private MaterialProperty specularSource = null ;
private MaterialProperty blendModeProp = null ;
private MaterialProperty albedoMapProp = null ;
private MaterialProperty albedoColorProp = null ;
private MaterialProperty alphaCutoffProp = null ;
private MaterialProperty specularSourceProp = null ;
private MaterialProperty specularGlossMap = null ;
private MaterialProperty specularColor = null ;
private MaterialProperty specularStrength = null ;
private MaterialProperty bumpMap = null ;
private MaterialProperty emissionColor = null ;
private MaterialProperty specularGlossMapProp = null ;
private MaterialProperty specularColorProp = null ;
private MaterialProperty shininessProp = null ;
private MaterialProperty bumpMapProp = null ;
private MaterialProperty emissionMapProp = null ;
private MaterialProperty emissionColorProp = null ;
public enum BlendMode
{
} ;
public static GUIContent normalMapText = new GUIContent ( "Normal Map" , "Normal Map" ) ;
public static GUIContent emissionMapLabel = new GUIContent ( "Emission Map" , "Emission Map" ) ;
public static GUIContent alphaCutoutWarning =
new GUIContent (
public static string albedoMapAlphaLabel = "Base(RGB) Alpha(A)" ;
public static string albedoMapGlossinessLabel = "Base(RGB) Glossiness (A)" ;
public static string alphaCutoffLabel = "Alpha Cutoff" ;
public static string specularStrength = "Specular Strength " ;
public static string shininessLabel = "Shininess " ;
public static string normalMapLabel = "Normal map" ;
public static string emissionColorLabel = "Emission Color" ;
}
Material [ ] mats = { material } ;
blendMode = GetMaterialProperty ( mats , "_Mode" ) ;
albedoMap = GetMaterialProperty ( mats , "_MainTex" ) ;
albedoColor = GetMaterialProperty ( mats , "_Color" ) ;
blendModeProp = GetMaterialProperty ( mats , "_Mode" ) ;
albedoMapProp = GetMaterialProperty ( mats , "_MainTex" ) ;
albedoColorProp = GetMaterialProperty ( mats , "_Color" ) ;
alphaCutoff = GetMaterialProperty ( mats , "_Cutoff" ) ;
specularSource = GetMaterialProperty ( mats , "_SpecSource" ) ;
alphaCutoffProp = GetMaterialProperty ( mats , "_Cutoff" ) ;
specularSourceProp = GetMaterialProperty ( mats , "_SpecSource" ) ;
specularGlossMap = GetMaterialProperty ( mats , "_SpecGlossMap" ) ;
specularColor = GetMaterialProperty ( mats , "_SpecColor" ) ;
specularStrength = GetMaterialProperty ( mats , "_SpecularStrength" ) ;
bumpMap = GetMaterialProperty ( mats , "_BumpMap" ) ;
emissionColor = GetMaterialProperty ( mats , "_EmissionColor" ) ;
specularGlossMapProp = GetMaterialProperty ( mats , "_SpecGlossMap" ) ;
specularColorProp = GetMaterialProperty ( mats , "_SpecColor" ) ;
shininessProp = GetMaterialProperty ( mats , "_Shininess" ) ;
bumpMapProp = GetMaterialProperty ( mats , "_BumpMap" ) ;
emissionMapProp = GetMaterialProperty ( mats , "_EmissionMap" ) ;
emissionColorProp = GetMaterialProperty ( mats , "_EmissionColor" ) ;
}
public override void OnInspectorGUI ( )
DoSpecular ( ) ;
EditorGUILayout . Space ( ) ;
TexturePropertySingleLine ( Styles . normalMapText , bumpMap ) ;
TexturePropertySingleLine ( Styles . normalMapText , bumpMapProp ) ;
ColorProperty ( emissionColor , Styles . emissionColorLabel ) ;
TexturePropertySingleLine ( Styles . emissionMapLabel , emissionMapProp , emissionColorProp ) ;
if ( EditorGUI . EndChangeCheck ( ) )
UpdateMaterialKeywords ( material ) ;
if ( ( BlendMode ) blendMode . floatValue = = BlendMode . Cutout )
if ( ( BlendMode ) blendModeProp . floatValue = = BlendMode . Cutout )
{
Styles . warningStyle . normal . textColor = Color . yellow ;
EditorGUILayout . LabelField ( Styles . alphaCutoutWarning , Styles . warningStyle ) ;
private void DoBlendMode ( )
{
int modeValue = ( int ) blendMode . floatValue ;
int modeValue = ( int ) blendModeProp . floatValue ;
blendMode . floatValue = modeValue ;
blendModeProp . floatValue = modeValue ;
BlendMode mode = ( BlendMode ) blendMode . floatValue ;
BlendMode mode = ( BlendMode ) blendModeProp . floatValue ;
EditorGUILayout . Space ( ) ;
TexturePropertySingleLine ( Styles . albedoGlosinessLabels [ glossSource ] , albedoMap , albedoColor ) ;
TextureScaleOffsetProperty ( albedoMap ) ;
TexturePropertySingleLine ( Styles . albedoGlosinessLabels [ glossSource ] , albedoMapProp , albedoColorProp ) ;
TextureScaleOffsetProperty ( albedoMapProp ) ;
TexturePropertySingleLine ( Styles . albedoAlphaLabel , albedoMap , albedoColor ) ;
TextureScaleOffsetProperty ( albedoMap ) ;
TexturePropertySingleLine ( Styles . albedoAlphaLabel , albedoMapProp , albedoColorProp ) ;
TextureScaleOffsetProperty ( albedoMapProp ) ;
RangeProperty ( alphaCutoff , "Cutoff" ) ;
RangeProperty ( alphaCutoffProp , "Cutoff" ) ;
}
}
int source = ( int ) specularSource . floatValue ;
int source = ( int ) specularSourceProp . floatValue ;
specularSource . floatValue = source ;
specularSourceProp . floatValue = source ;
SpecularSource specSource = ( SpecularSource ) specularSource . floatValue ;
SpecularSource specSource = ( SpecularSource ) specularSourceProp . floatValue ;
if ( specSource ! = SpecularSource . NoSpecular )
{
int glossinessSource = ( int ) glossinessSourceProp . floatValue ;
int glossSource = ( int ) glossinessSourceProp . floatValue ;
if ( specSource = = SpecularSource . SpecularTextureAndColor )
{
TexturePropertySingleLine ( Styles . specularGlossMapLabels [ glossSource ] , specularGlossMap , specularColor ) ;
TexturePropertySingleLine ( Styles . specularGlossMapLabels [ glossSource ] , specularGlossMapProp , specularColorProp ) ;
RangeProperty ( specularStrength , Styles . specularStrength ) ;
RangeProperty ( shininessProp , Styles . shininessLabel ) ;
}
}
private void UpdateMaterialBlendMode ( Material material )
{
BlendMode mode = ( BlendMode ) blendMode . floatValue ;
BlendMode mode = ( BlendMode ) blendModeProp . floatValue ;
switch ( mode )
{
case BlendMode . Opaque :
private void UpdateMaterialSpecularSource ( Material material )
{
SpecularSource specSource = ( SpecularSource ) specularSource . floatValue ;
SpecularSource specSource = ( SpecularSource ) specularSourceProp . floatValue ;
if ( specSource = = SpecularSource . NoSpecular )
{
SetKeyword ( material , "_SHARED_SPECULAR_DIFFUSE" , false ) ;