DoubleSidedLightingMirror ,
}
public enum NormalMapSpace
{
TangentSpace ,
ObjectSpace ,
}
public enum HeightmapMode
{
Parallax ,
Displacement ,
}
private static class Styles
{
public static string OptionText = "Options" ;
public static GUIContent specularOcclusionMapText = new GUIContent ( "Specular Occlusion Map (RGBA)" , "Specular Occlusion Map" ) ;
public static GUIContent normalMapText = new GUIContent ( "Normal Map" , "Normal Map (BC5) - DXT5 for test" ) ;
public static GUIContent normalMapSpaceText = new GUIContent ( "Normal Map space" , "" ) ;
public static GUIContent heightMapModeText = new GUIContent ( "Height Map Mode" , "" ) ;
// public static GUIContent diffuseLightingMapText = new GUIContent("DiffuseLightingMap", "Lightmap/Lightprobe data (fill by system is not done");
MaterialProperty maskMap = null ;
MaterialProperty specularOcclusionMap = null ;
MaterialProperty normalMap = null ;
MaterialProperty normalMapSpace = null ;
MaterialProperty heightMapMode = null ;
// MaterialProperty diffuseLightingMap = null;
MaterialProperty emissiveColor = null ;
MaterialProperty emissiveColorMap = null ;
MaterialEditor m_MaterialEditor ;
ColorPickerHDRConfig m_ColorPickerHDRConfig = new ColorPickerHDRConfig ( 0f , 9 9f , 1 / 9 9f , 3f ) ;
bool m_FirstTimeApply = true ;
MaterialEditor m_MaterialEditor ;
alphaCutoff = FindProperty ( "_Cutoff" , props ) ;
alphaCutoff = FindProperty ( "_AlphaCutoff" , props ) ;
alphaCutoffEnable = FindProperty ( "_AlphaCutoffEnable" , props ) ;
doubleSidedMode = FindProperty ( "_DoubleSidedMode" , props ) ;
smoothnessMapChannel = FindProperty ( "_SmoothnessTextureChannel" , props ) ;
maskMap = FindProperty ( "_MaskMap" , props ) ;
specularOcclusionMap = FindProperty ( "_SpecularOcclusionMap" , props ) ;
normalMap = FindProperty ( "_NormalMap" , props ) ;
normalMapSpace = FindProperty ( "_NormalMapSpace" , props ) ;
heightMapMode = FindProperty ( "_HeightMapMode" , props ) ;
// diffuseLightingMap = FindProperty("_DiffuseLightingMap", props);
emissiveColor = FindProperty ( "_EmissiveColor" , props ) ;
emissiveColorMap = FindProperty ( "_EmissiveColorMap" , props ) ;
EditorGUI . BeginChangeCheck ( ) ;
{
GUILayout . Label ( Styles . OptionText , EditorStyles . boldLabel ) ;
SurfaceTypePopup ( ) ;
SurfaceTypePopup ( ) ;
if ( ( SurfaceType ) surfaceType . floatValue = = SurfaceType . Transparent )
{
BlendModePopup ( ) ;
}
}
if ( ( SurfaceType ) surfaceType . floatValue = = SurfaceType . Transparent )
{
BlendModePopup ( ) ;
}
m_MaterialEditor . ShaderProperty ( doubleSidedMode , Styles . doubleSidedModeText . text ) ;
m_MaterialEditor . TexturePropertySingleLine ( Styles . specularOcclusionMapText , specularOcclusionMap ) ;
m_MaterialEditor . TexturePropertySingleLine ( Styles . normalMapText , normalMap ) ;
m_MaterialEditor . ShaderProperty ( normalMapSpace , Styles . normalMapSpaceText . text ) ;
m_MaterialEditor . ShaderProperty ( heightMapMode , Styles . heightMapModeText . text ) ;
if ( ! useEmissiveMask )
{
EditorGUI . showMixedValue = false ;
}
public void SetupMaterialWithBlendMode ( Material material , bool alphaTestEnable , SurfaceType surfaceType , BlendMode blendMode , DoubleSidedMode doubleSidedMode )
static public void SetupMaterialWithBlendMode ( Material material , bool alphaTestEnable , SurfaceType surfaceType , BlendMode blendMode , DoubleSidedMode doubleSidedMode )
{
if ( alphaTestEnable )
material . EnableKeyword ( "_ALPHATEST_ON" ) ;
}
}
if ( doubleSidedMode = = DoubleSidedMode . DoubleSided )
if ( doubleSidedMode ! = DoubleSidedMode . None )
else if ( doubleSidedMode = = DoubleSidedMode . DoubleSided )
if ( doubleSidedMode = = DoubleSidedMode . DoubleSided )
material . SetInt ( "_CullMode" , ( int ) UnityEngine . Rendering . CullMode . Off ) ;
material . DisableKeyword ( "_DOUBLESIDED_LIGHTING_MIRROR" ) ;
material . SetInt ( "_CullMode" , ( int ) UnityEngine . Rendering . CullMode . Off ) ;
material . DisableKeyword ( "_DOUBLESIDED_LIGHTING_FLIP" ) ;
}
}
}
static bool ShouldEmissionBeEnabled ( Material mat , Color color )
return false ;
}
void SetMaterialKeywords ( Material material )
static void SetMaterialKeywords ( Material material )
SetKeyword ( material , "_NORMALMAP_TANGENT_SPACE" , ( NormalMapSpace ) material . GetFloat ( "_NormalMapSpace" ) = = NormalMapSpace . TangentSpace ) ;
SetKeyword ( material , "_HEIGHTMAP" , material . GetTexture ( "_HeightMap" ) ) ;
SetKeyword ( material , "_HEIGHTMAP_AS_DISPLACEMENT" , ( HeightmapMode ) material . GetFloat ( "_HeightMapMode" ) = = HeightmapMode . Displacement ) ;
/ *
// Setup lightmap emissive flags
return true ;
}
void MaterialChanged ( Material material )
static void MaterialChanged ( Material material )
SetupMaterialWithBlendMode ( material , alphaCutoffEnable . floatValue = = 1.0 , ( SurfaceType ) surfaceType . floatValue , ( BlendMode ) blendMode . floatValue , ( DoubleSidedMode ) doubleSidedMode . floatValue ) ;
SetupMaterialWithBlendMode ( material , material . GetFloat ( "_AlphaCutoffEnable" ) = = 1.0 , ( SurfaceType ) material . GetFloat ( "_SurfaceType" ) , ( BlendMode ) material . GetFloat ( "_BlendMode" ) , ( DoubleSidedMode ) material . GetFloat ( "_DoubleSidedMode" ) ) ;
void SetKeyword ( Material m , string keyword , bool state )
static void SetKeyword ( Material m , string keyword , bool state )
{
if ( state )
m . EnableKeyword ( keyword ) ;