44
55public class LowendMobilePipelineMaterialEditor : MaterialEditor
66{
7- private MaterialProperty blendMode = null ;
8- private MaterialProperty albedoMap = null ;
9- private MaterialProperty albedoColor = null ;
10- private MaterialProperty alphaCutoff = null ;
11- private MaterialProperty specularSource = null ;
7+ private MaterialProperty blendModeProp = null ;
8+ private MaterialProperty albedoMapProp = null ;
9+ private MaterialProperty albedoColorProp = null ;
10+ private MaterialProperty alphaCutoffProp = null ;
11+ private MaterialProperty specularSourceProp = null ;
1212 private MaterialProperty glossinessSourceProp = null ;
13- private MaterialProperty specularGlossMap = null ;
14- private MaterialProperty specularColor = null ;
15- private MaterialProperty specularStrength = null ;
16- private MaterialProperty bumpMap = null ;
17- private MaterialProperty emissionColor = null ;
13+ private MaterialProperty specularGlossMapProp = null ;
14+ private MaterialProperty specularColorProp = null ;
15+ private MaterialProperty shininessProp = null ;
16+ private MaterialProperty bumpMapProp = null ;
17+ private MaterialProperty emissionMapProp = null ;
18+ private MaterialProperty emissionColorProp = null ;
1819
1920 public enum BlendMode
2021 {
@@ -63,6 +64,7 @@ private static class Styles
6364 } ;
6465
6566 public static GUIContent normalMapText = new GUIContent ( "Normal Map" , "Normal Map" ) ;
67+ public static GUIContent emissionMapLabel = new GUIContent ( "Emission Map" , "Emission Map" ) ;
6668
6769 public static GUIContent alphaCutoutWarning =
6870 new GUIContent (
@@ -81,26 +83,27 @@ private static class Styles
8183 public static string albedoMapAlphaLabel = "Base(RGB) Alpha(A)" ;
8284 public static string albedoMapGlossinessLabel = "Base(RGB) Glossiness (A)" ;
8385 public static string alphaCutoffLabel = "Alpha Cutoff" ;
84- public static string specularStrength = "Specular Strength " ;
86+ public static string shininessLabel = "Shininess " ;
8587 public static string normalMapLabel = "Normal map" ;
8688 public static string emissionColorLabel = "Emission Color" ;
8789 }
8890
8991 private void FindMaterialProperties ( Material material )
9092 {
9193 Material [ ] mats = { material } ;
92- blendMode = GetMaterialProperty ( mats , "_Mode" ) ;
93- albedoMap = GetMaterialProperty ( mats , "_MainTex" ) ;
94- albedoColor = GetMaterialProperty ( mats , "_Color" ) ;
94+ blendModeProp = GetMaterialProperty ( mats , "_Mode" ) ;
95+ albedoMapProp = GetMaterialProperty ( mats , "_MainTex" ) ;
96+ albedoColorProp = GetMaterialProperty ( mats , "_Color" ) ;
9597
96- alphaCutoff = GetMaterialProperty ( mats , "_Cutoff" ) ;
97- specularSource = GetMaterialProperty ( mats , "_SpecSource" ) ;
98+ alphaCutoffProp = GetMaterialProperty ( mats , "_Cutoff" ) ;
99+ specularSourceProp = GetMaterialProperty ( mats , "_SpecSource" ) ;
98100 glossinessSourceProp = GetMaterialProperty ( mats , "_GlossinessSource" ) ;
99- specularGlossMap = GetMaterialProperty ( mats , "_SpecGlossMap" ) ;
100- specularColor = GetMaterialProperty ( mats , "_SpecColor" ) ;
101- specularStrength = GetMaterialProperty ( mats , "_SpecularStrength" ) ;
102- bumpMap = GetMaterialProperty ( mats , "_BumpMap" ) ;
103- emissionColor = GetMaterialProperty ( mats , "_EmissionColor" ) ;
101+ specularGlossMapProp = GetMaterialProperty ( mats , "_SpecGlossMap" ) ;
102+ specularColorProp = GetMaterialProperty ( mats , "_SpecColor" ) ;
103+ shininessProp = GetMaterialProperty ( mats , "_Shininess" ) ;
104+ bumpMapProp = GetMaterialProperty ( mats , "_BumpMap" ) ;
105+ emissionMapProp = GetMaterialProperty ( mats , "_EmissionMap" ) ;
106+ emissionColorProp = GetMaterialProperty ( mats , "_EmissionColor" ) ;
104107 }
105108
106109 public override void OnInspectorGUI ( )
@@ -119,18 +122,18 @@ public override void OnInspectorGUI()
119122 DoSpecular ( ) ;
120123
121124 EditorGUILayout . Space ( ) ;
122- TexturePropertySingleLine ( Styles . normalMapText , bumpMap ) ;
125+ TexturePropertySingleLine ( Styles . normalMapText , bumpMapProp ) ;
123126
124127 EditorGUILayout . Space ( ) ;
125- ColorProperty ( emissionColor , Styles . emissionColorLabel ) ;
128+ TexturePropertySingleLine ( Styles . emissionMapLabel , emissionMapProp , emissionColorProp ) ;
126129
127130 if ( EditorGUI . EndChangeCheck ( ) )
128131 UpdateMaterialKeywords ( material ) ;
129132
130133 EditorGUILayout . Space ( ) ;
131134 EditorGUILayout . Space ( ) ;
132135
133- if ( ( BlendMode ) blendMode . floatValue == BlendMode . Cutout )
136+ if ( ( BlendMode ) blendModeProp . floatValue == BlendMode . Cutout )
134137 {
135138 Styles . warningStyle . normal . textColor = Color . yellow ;
136139 EditorGUILayout . LabelField ( Styles . alphaCutoutWarning , Styles . warningStyle ) ;
@@ -140,46 +143,46 @@ public override void OnInspectorGUI()
140143
141144 private void DoBlendMode ( )
142145 {
143- int modeValue = ( int ) blendMode . floatValue ;
146+ int modeValue = ( int ) blendModeProp . floatValue ;
144147 EditorGUI . BeginChangeCheck ( ) ;
145148 modeValue = EditorGUILayout . Popup ( Styles . renderingModeLabel , modeValue , Styles . blendNames ) ;
146149 if ( EditorGUI . EndChangeCheck ( ) )
147- blendMode . floatValue = modeValue ;
150+ blendModeProp . floatValue = modeValue ;
148151
149- BlendMode mode = ( BlendMode ) blendMode . floatValue ;
152+ BlendMode mode = ( BlendMode ) blendModeProp . floatValue ;
150153
151154 EditorGUILayout . Space ( ) ;
152155
153156 if ( mode == BlendMode . Opaque )
154157 {
155158 int glossSource = ( int ) glossinessSourceProp . floatValue ;
156- TexturePropertySingleLine ( Styles . albedoGlosinessLabels [ glossSource ] , albedoMap , albedoColor ) ;
157- TextureScaleOffsetProperty ( albedoMap ) ;
159+ TexturePropertySingleLine ( Styles . albedoGlosinessLabels [ glossSource ] , albedoMapProp , albedoColorProp ) ;
160+ TextureScaleOffsetProperty ( albedoMapProp ) ;
158161 }
159162 else
160163 {
161- TexturePropertySingleLine ( Styles . albedoAlphaLabel , albedoMap , albedoColor ) ;
162- TextureScaleOffsetProperty ( albedoMap ) ;
164+ TexturePropertySingleLine ( Styles . albedoAlphaLabel , albedoMapProp , albedoColorProp ) ;
165+ TextureScaleOffsetProperty ( albedoMapProp ) ;
163166 if ( mode == BlendMode . Cutout )
164- RangeProperty ( alphaCutoff , "Cutoff" ) ;
167+ RangeProperty ( alphaCutoffProp , "Cutoff" ) ;
165168 }
166169 }
167170
168171 private void DoSpecular ( )
169172 {
170173 EditorGUILayout . Space ( ) ;
171174
172- int source = ( int ) specularSource . floatValue ;
175+ int source = ( int ) specularSourceProp . floatValue ;
173176 EditorGUI . BeginChangeCheck ( ) ;
174177 source = EditorGUILayout . Popup ( Styles . specularSourceLabel , source , Styles . specSourceNames ) ;
175178 if ( EditorGUI . EndChangeCheck ( ) )
176179 {
177- specularSource . floatValue = source ;
180+ specularSourceProp . floatValue = source ;
178181 if ( source == ( int ) SpecularSource . BaseTexture )
179182 glossinessSourceProp . floatValue = ( float ) GlossinessSource . BaseAlpha ;
180183 }
181184
182- SpecularSource specSource = ( SpecularSource ) specularSource . floatValue ;
185+ SpecularSource specSource = ( SpecularSource ) specularSourceProp . floatValue ;
183186 if ( specSource != SpecularSource . NoSpecular )
184187 {
185188 int glossinessSource = ( int ) glossinessSourceProp . floatValue ;
@@ -193,12 +196,12 @@ private void DoSpecular()
193196 int glossSource = ( int ) glossinessSourceProp . floatValue ;
194197 if ( specSource == SpecularSource . SpecularTextureAndColor )
195198 {
196- TexturePropertySingleLine ( Styles . specularGlossMapLabels [ glossSource ] , specularGlossMap , specularColor ) ;
199+ TexturePropertySingleLine ( Styles . specularGlossMapLabels [ glossSource ] , specularGlossMapProp , specularColorProp ) ;
197200 }
198201
199202 if ( specSource != SpecularSource . NoSpecular )
200203 {
201- RangeProperty ( specularStrength , Styles . specularStrength ) ;
204+ RangeProperty ( shininessProp , Styles . shininessLabel ) ;
202205 }
203206 }
204207
@@ -212,7 +215,7 @@ private void UpdateMaterialKeywords(Material material)
212215
213216 private void UpdateMaterialBlendMode ( Material material )
214217 {
215- BlendMode mode = ( BlendMode ) blendMode . floatValue ;
218+ BlendMode mode = ( BlendMode ) blendModeProp . floatValue ;
216219 switch ( mode )
217220 {
218221 case BlendMode . Opaque :
@@ -246,7 +249,7 @@ private void UpdateMaterialBlendMode(Material material)
246249
247250 private void UpdateMaterialSpecularSource ( Material material )
248251 {
249- SpecularSource specSource = ( SpecularSource ) specularSource . floatValue ;
252+ SpecularSource specSource = ( SpecularSource ) specularSourceProp . floatValue ;
250253 if ( specSource == SpecularSource . NoSpecular )
251254 {
252255 SetKeyword ( material , "_SHARED_SPECULAR_DIFFUSE" , false ) ;
0 commit comments