20 PremultipliedTransparent,
47 public static string primaryMapsTitle =
"Main Maps";
48 public static string renderingOptionsTitle =
"Rendering Options";
49 public static string advancedOptionsTitle =
"Advanced Options";
50 public static string fluentOptionsTitle =
"Fluent Options";
51 public static string renderTypeName =
"RenderType";
52 public static string renderingModeName =
"_Mode";
53 public static string customRenderingModeName =
"_CustomMode";
54 public static string sourceBlendName =
"_SrcBlend";
55 public static string destinationBlendName =
"_DstBlend";
56 public static string blendOperationName =
"_BlendOp";
57 public static string depthTestName =
"_ZTest";
58 public static string depthWriteName =
"_ZWrite";
59 public static string colorWriteMaskName =
"_ColorWriteMask";
60 public static string alphaTestOnName =
"_ALPHATEST_ON";
61 public static string alphaBlendOnName =
"_ALPHABLEND_ON";
62 public static string disableAlbedoMapName =
"_DISABLE_ALBEDO_MAP";
63 public static string albedoMapAlphaMetallicName =
"_METALLIC_TEXTURE_ALBEDO_CHANNEL_A";
64 public static string albedoMapAlphaSmoothnessName =
"_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A";
65 public static readonly
string[] renderingModeNames = Enum.GetNames(typeof(
RenderingMode));
66 public static readonly
string[] customRenderingModeNames = Enum.GetNames(typeof(
CustomRenderingMode));
67 public static readonly
string[] albedoAlphaModeNames = Enum.GetNames(typeof(
AlbedoAlphaMode));
68 public static readonly
string[] depthWriteNames = Enum.GetNames(typeof(
DepthWrite));
69 public static GUIContent sourceBlend =
new GUIContent(
"Source Blend",
"Blend Mode of Newly Calculated Color");
70 public static GUIContent destinationBlend =
new GUIContent(
"Destination Blend",
"Blend Mode of Existing Color");
71 public static GUIContent blendOperation =
new GUIContent(
"Blend Operation",
"Operation for Blending New Color With Existing Color");
72 public static GUIContent depthTest =
new GUIContent(
"Depth Test",
"How Should Depth Testing Be Performed.");
73 public static GUIContent depthWrite =
new GUIContent(
"Depth Write",
"Controls Whether Pixels From This Object Are Written to the Depth Buffer");
74 public static GUIContent colorWriteMask =
new GUIContent(
"Color Write Mask",
"Color Channel Writing Mask");
75 public static GUIContent cullMode =
new GUIContent(
"Cull Mode",
"Triangle Culling Mode");
76 public static GUIContent renderQueueOverride =
new GUIContent(
"Render Queue Override",
"Manually Override the Render Queue");
77 public static GUIContent albedo =
new GUIContent(
"Albedo",
"Albedo (RGB) and Transparency (A)");
78 public static GUIContent alphaCutoff =
new GUIContent(
"Alpha Cutoff",
"Threshold for Alpha Cutoff");
79 public static GUIContent metallic =
new GUIContent(
"Metallic",
"Metallic Value");
80 public static GUIContent smoothness =
new GUIContent(
"Smoothness",
"Smoothness Value");
81 public static GUIContent enableNormalMap =
new GUIContent(
"Normal Map",
"Enable Normal Map");
82 public static GUIContent normalMap =
new GUIContent(
"Normal Map");
83 public static GUIContent enableEmission =
new GUIContent(
"Emission",
"Enable Emission");
84 public static GUIContent emissiveColor =
new GUIContent(
"Color");
85 public static GUIContent directionalLight =
new GUIContent(
"Directional Light",
"Affected by Unity Directional Light");
86 public static GUIContent specularHighlights =
new GUIContent(
"Specular Highlights",
"Calculate Specular Highlights");
87 public static GUIContent reflections =
new GUIContent(
"Reflections",
"Calculate Glossy Reflections");
88 public static GUIContent refraction =
new GUIContent(
"Refraction",
"Calculate Refraction");
89 public static GUIContent refractiveIndex =
new GUIContent(
"Refractive Index",
"Ratio of Indices of Refraction at the Surface Interface");
90 public static GUIContent rimLight =
new GUIContent(
"Rim Light",
"Enable Rim/Edge Lighting");
91 public static GUIContent rimColor =
new GUIContent(
"Color",
"Rim Highlight Color");
92 public static GUIContent rimPower =
new GUIContent(
"Power",
"Rim Highlight Saturation");
93 public static GUIContent clippingPlane =
new GUIContent(
"Clipping Plane",
"Enable Clipping Against a Plane");
94 public static GUIContent clipPlane =
new GUIContent(
"Plane",
"Plane To Clip Against");
95 public static GUIContent clippingPlaneBorder =
new GUIContent(
"Border",
"Enable a Border Along the Clipping Plane");
96 public static GUIContent clippingPlaneBorderWidth =
new GUIContent(
"Width",
"Width of the Clipping Plane Border");
97 public static GUIContent clippingPlaneBorderColor =
new GUIContent(
"Color",
"Interpolated Color of the Clipping Plane Border");
98 public static GUIContent nearPlaneFade =
new GUIContent(
"Near Plane Fade",
"Objects Disappear (Turn to Black) as the Camera Nears Them");
99 public static GUIContent fadeBeginDistance =
new GUIContent(
"Fade Begin",
"Distance From Camera to Begin Fade In");
100 public static GUIContent fadeCompleteDistance =
new GUIContent(
"Fade Complete",
"Distance From Camera When Fade is Fully In");
101 public static GUIContent hoverLight =
new GUIContent(
"Hover Light",
"Enable utilization of a Hover Light");
102 public static GUIContent enableHoverColorOverride =
new GUIContent(
"Override Color",
"Override Global Hover Color");
103 public static GUIContent hoverLightOpaque =
new GUIContent(
"Hover Light Opaque",
"Enable Hover Light on Transparent Pixels");
104 public static GUIContent enableHoverColorOpaqueOverride =
new GUIContent(
"Override Color",
"Override Opaque Hover Color");
105 public static GUIContent hoverColorOpaqueOverride =
new GUIContent(
"Color",
"Override Hover Color for Transparent Pixels");
106 public static GUIContent hoverColorOverride =
new GUIContent(
"Color",
"Override Hover Color");
107 public static GUIContent roundCorners =
new GUIContent(
"Round Corners",
"(Assumes UVs Specify Borders)");
108 public static GUIContent roundCornerRadius =
new GUIContent(
"Unit Radius",
"Rounded Rectangle Corner Unit Sphere Radius");
109 public static GUIContent roundCornerMargin =
new GUIContent(
"Margin %",
"Distance From Geometry Edge");
110 public static GUIContent borderLight =
new GUIContent(
"Border Light",
"Enable Border Lighting (Assumes UVs Specify Borders)");
111 public static GUIContent borderLightUsesHoverColor =
new GUIContent(
"Use Hover Color",
"Border Color Comes From Hover Light");
112 public static GUIContent borderLightOpaque =
new GUIContent(
"Opaque Borders",
"Borders Override Alpha Value to Appear Opaque");
113 public static GUIContent borderWidth =
new GUIContent(
"Width %",
"Uniform Width Along Border as a % of the Smallest XYZ Dimension");
114 public static GUIContent borderMinValue =
new GUIContent(
"Min Value",
"Minimum Border Saturation");
115 public static GUIContent edgeSmoothingValue =
new GUIContent(
"Edge Smoothing Value",
"Smooths Edges When Round Corners and Transparency Is Enabled");
116 public static GUIContent innerGlow =
new GUIContent(
"Inner Glow",
"Enable Inner Glow (Assumes UVs Specify Borders)");
117 public static GUIContent innerGlowColor =
new GUIContent(
"Color",
"Inner Glow Color (RGB) and Intensity (A)");
118 public static GUIContent environmentColoring =
new GUIContent(
"Environment Coloring",
"Change Color Based on View");
119 public static GUIContent environmentColorThreshold =
new GUIContent(
"Threshold",
"Threshold When Environment Coloring Should Appear Based on Surface Normal");
120 public static GUIContent environmentColorIntensity =
new GUIContent(
"Intensity",
"Intensity (or Brightness) of the Environment Coloring");
121 public static GUIContent environmentColorX =
new GUIContent(
"X-Axis Color",
"Color Along the World Space X-Axis");
122 public static GUIContent environmentColorY =
new GUIContent(
"Y-Axis Color",
"Color Along the World Space Y-Axis");
123 public static GUIContent environmentColorZ =
new GUIContent(
"Z-Axis Color",
"Color Along the World Space Z-Axis");
198 cullMode = FindProperty(
"_CullMode", props);
199 renderQueueOverride = FindProperty(
"_RenderQueueOverride", props);
200 albedoMap = FindProperty(
"_MainTex", props);
201 albedoColor = FindProperty(
"_Color", props);
202 albedoAlphaMode = FindProperty(
"_AlbedoAlphaMode", props);
203 alphaCutoff = FindProperty(
"_Cutoff", props);
204 metallic = FindProperty(
"_Metallic", props);
205 smoothness = FindProperty(
"_Smoothness", props);
206 enableNormalMap = FindProperty(
"_EnableNormalMap", props);
207 normalMap = FindProperty(
"_NormalMap", props);
208 enableEmission = FindProperty(
"_EnableEmission", props);
209 emissiveColor = FindProperty(
"_EmissiveColor", props);
210 directionalLight = FindProperty(
"_DirectionalLight", props);
211 specularHighlights = FindProperty(
"_SpecularHighlights", props);
212 reflections = FindProperty(
"_Reflections", props);
213 refraction = FindProperty(
"_Refraction", props);
214 refractiveIndex = FindProperty(
"_RefractiveIndex", props);
215 rimLight = FindProperty(
"_RimLight", props);
216 rimColor = FindProperty(
"_RimColor", props);
217 rimPower = FindProperty(
"_RimPower", props);
218 clippingPlane = FindProperty(
"_ClippingPlane", props);
219 clipPlane = FindProperty(
"_ClipPlane", props);
220 clippingPlaneBorder = FindProperty(
"_ClippingPlaneBorder", props);
221 clippingPlaneBorderWidth = FindProperty(
"_ClippingPlaneBorderWidth", props);
222 clippingPlaneBorderColor = FindProperty(
"_ClippingPlaneBorderColor", props);
223 nearPlaneFade = FindProperty(
"_NearPlaneFade", props);
224 fadeBeginDistance = FindProperty(
"_FadeBeginDistance", props);
225 fadeCompleteDistance = FindProperty(
"_FadeCompleteDistance", props);
226 hoverLight = FindProperty(
"_HoverLight", props);
227 enableHoverColorOverride = FindProperty(
"_EnableHoverColorOverride", props);
228 hoverColorOverride = FindProperty(
"_HoverColorOverride", props);
229 hoverLightOpaque = FindProperty(
"_HoverLightOpaque", props);
230 enableHoverColorOpaqueOverride = FindProperty(
"_EnableHoverColorOpaqueOverride", props);
231 hoverColorOverrideOpaque = FindProperty(
"_HoverColorOpaqueOverride", props);
232 roundCorners = FindProperty(
"_RoundCorners", props);
233 roundCornerRadius = FindProperty(
"_RoundCornerRadius", props);
234 roundCornerMargin = FindProperty(
"_RoundCornerMargin", props);
235 borderLight = FindProperty(
"_BorderLight", props);
236 borderLightUsesHoverColor = FindProperty(
"_BorderLightUsesHoverColor", props);
237 borderLightOpaque = FindProperty(
"_BorderLightOpaque", props);
238 borderWidth = FindProperty(
"_BorderWidth", props);
239 borderMinValue = FindProperty(
"_BorderMinValue", props);
240 edgeSmoothingValue = FindProperty(
"_EdgeSmoothingValue", props);
241 innerGlow = FindProperty(
"_InnerGlow", props);
242 innerGlowColor = FindProperty(
"_InnerGlowColor", props);
243 environmentColoring = FindProperty(
"_EnvironmentColoring", props);
244 environmentColorThreshold = FindProperty(
"_EnvironmentColorThreshold", props);
245 environmentColorIntensity = FindProperty(
"_EnvironmentColorIntensity", props);
246 environmentColorX = FindProperty(
"_EnvironmentColorX", props);
247 environmentColorY = FindProperty(
"_EnvironmentColorY", props);
248 environmentColorZ = FindProperty(
"_EnvironmentColorZ", props);
251 public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
253 Material material = (Material)materialEditor.target;
255 FindProperties(props);
256 Initialize(material);
258 RenderingModeOptions(materialEditor);
259 MainMapOptions(materialEditor, material);
260 RenderingOptions(materialEditor, material);
261 FluentOptions(materialEditor, material);
262 AdvancedOptions(materialEditor, material);
268 float? smoothness = GetFloatProperty(material,
"_Glossiness");
269 float? diffuse = GetFloatProperty(material,
"_UseDiffuse");
270 float? specularHighlights = GetFloatProperty(material,
"_SpecularHighlights");
271 float? normalMap = null;
272 Texture normalMapTexture = material.GetTexture(
"_BumpMap");
273 float? emission = null;
274 Color? emissionColor = GetColorProperty(material,
"_EmissionColor");
275 float? reflections = null;
276 float? rimLighting = null;
277 Vector4? textureScaleOffset = null;
278 float? cullMode = GetFloatProperty(material,
"_Cull");
282 if (oldShader.name.Contains(
"Standard"))
284 normalMap = material.IsKeywordEnabled(
"_NORMALMAP") ? 1.0f : 0.0f;
285 emission = material.IsKeywordEnabled(
"_EMISSION") ? 1.0f : 0.0f;
286 reflections = GetFloatProperty(material,
"_GlossyReflections");
288 else if (oldShader.name.Contains(
"Fast Configurable"))
290 normalMap = material.IsKeywordEnabled(
"_USEBUMPMAP_ON") ? 1.0f : 0.0f;
291 emission = GetFloatProperty(material,
"_UseEmissionColor");
292 reflections = GetFloatProperty(material,
"_UseReflections");
293 rimLighting = GetFloatProperty(material,
"_UseRimLighting");
294 textureScaleOffset = GetVectorProperty(material,
"_TextureScaleOffset");
298 base.AssignNewShaderToMaterial(material, oldShader, newShader);
301 SetFloatProperty(material, null,
"_Smoothness", smoothness);
302 SetFloatProperty(material,
"_DIRECTIONAL_LIGHT",
"_DirectionalLight", diffuse);
303 SetFloatProperty(material,
"_SPECULAR_HIGHLIGHTS",
"_SpecularHighlights", specularHighlights);
304 SetFloatProperty(material,
"_NORMAL_MAP",
"_EnableNormalMap", normalMap);
306 if (normalMapTexture)
308 material.SetTexture(
"_NormalMap", normalMapTexture);
311 SetFloatProperty(material,
"_EMISSION",
"_EnableEmission", emission);
312 SetColorProperty(material,
"_EmissiveColor", emissionColor);
313 SetFloatProperty(material,
"_REFLECTIONS",
"_Reflections", reflections);
314 SetFloatProperty(material,
"_RIM_LIGHT",
"_RimLight", rimLighting);
315 SetVectorProperty(material,
"_MainTex_ST", textureScaleOffset);
316 SetFloatProperty(material, null,
"_CullMode", cullMode);
319 if (oldShader == null || !oldShader.name.Contains(
"Legacy Shaders/"))
327 if (oldShader.name.Contains(
"/Transparent/Cutout/"))
331 else if (oldShader.name.Contains(
"/Transparent/"))
338 MaterialChanged(material);
346 MaterialChanged(material);
353 SetupMaterialWithAlbedo(material, albedoMap, albedoAlphaMode);
354 SetupMaterialWithRenderingMode(material, (
RenderingMode)renderingMode.floatValue, (
CustomRenderingMode)customRenderingMode.floatValue, (
int)renderQueueOverride.floatValue);
359 EditorGUI.BeginChangeCheck();
361 EditorGUI.showMixedValue = renderingMode.hasMixedValue;
363 EditorGUI.BeginChangeCheck();
366 if (EditorGUI.EndChangeCheck())
368 materialEditor.RegisterPropertyChangeUndo(renderingMode.displayName);
369 renderingMode.floatValue = (float)mode;
372 EditorGUI.showMixedValue =
false;
374 if (EditorGUI.EndChangeCheck())
376 UnityEngine.Object[] targets = renderingMode.targets;
380 MaterialChanged((Material)target);
386 EditorGUI.indentLevel += 2;
387 customRenderingMode.floatValue = EditorGUILayout.Popup(customRenderingMode.displayName, (
int)customRenderingMode.floatValue,
Styles.
customRenderingModeNames);
392 depthWrite.floatValue = EditorGUILayout.Popup(depthWrite.displayName, (
int)depthWrite.floatValue,
Styles.
depthWriteNames);
394 EditorGUI.indentLevel -= 2;
404 materialEditor.TexturePropertySingleLine(
Styles.
albedo, albedoMap, albedoColor);
406 EditorGUI.indentLevel += 2;
408 albedoAlphaMode.floatValue = EditorGUILayout.Popup(albedoAlphaMode.displayName, (
int)albedoAlphaMode.floatValue,
Styles.
albedoAlphaModeNames);
425 SetupMaterialWithAlbedo(material, albedoMap, albedoAlphaMode);
427 EditorGUI.indentLevel -= 2;
429 if (PropertyEnabled(directionalLight) ||
430 PropertyEnabled(reflections) ||
431 PropertyEnabled(rimLight) ||
432 PropertyEnabled(environmentColoring))
436 if (PropertyEnabled(enableNormalMap))
444 if (PropertyEnabled(enableEmission))
449 EditorGUILayout.Space();
450 materialEditor.TextureScaleOffsetProperty(albedoMap);
455 EditorGUILayout.Space();
460 if (PropertyEnabled(directionalLight))
467 if (PropertyEnabled(reflections))
471 if (PropertyEnabled(refraction))
479 if (PropertyEnabled(rimLight))
487 if (PropertyEnabled(clippingPlane))
492 if (PropertyEnabled(clippingPlaneBorder))
501 if (PropertyEnabled(nearPlaneFade))
508 protected void FluentOptions(MaterialEditor materialEditor, Material material)
510 EditorGUILayout.Space();
517 if (PropertyEnabled(hoverLight))
521 if (PropertyEnabled(enableHoverColorOverride))
531 if (PropertyEnabled(hoverLightOpaque))
535 if (PropertyEnabled(enableHoverColorOpaqueOverride))
544 if (PropertyEnabled(roundCorners))
552 if (PropertyEnabled(borderLight))
554 if (PropertyEnabled(hoverLight))
568 if (!PropertyEnabled(borderLightOpaque))
574 if (PropertyEnabled(roundCorners) || PropertyEnabled(borderLight))
581 if (PropertyEnabled(innerGlow))
588 if (PropertyEnabled(environmentColoring))
600 EditorGUILayout.Space();
603 EditorGUI.BeginChangeCheck();
607 if (EditorGUI.EndChangeCheck())
609 MaterialChanged(material);
614 materialEditor.RenderQueueField();
618 GUI.enabled = !PropertyEnabled(roundCorners) && !PropertyEnabled(borderLight);
620 if (!GUI.enabled && !material.enableInstancing)
622 material.enableInstancing =
true;
625 materialEditor.EnableInstancingField();
628 protected static void SetupMaterialWithAlbedo(Material material, MaterialProperty albedoMap, MaterialProperty albedoAlphaMode)
630 if (albedoMap.textureValue)
680 material.renderQueue = (renderQueueOverride >= 0) ? renderQueueOverride : (
int)
UnityEngine.Rendering.RenderQueue.Geometry;
696 material.renderQueue = (renderQueueOverride >= 0) ? renderQueueOverride : (
int)
UnityEngine.Rendering.RenderQueue.AlphaTest;
712 material.renderQueue = (renderQueueOverride >= 0) ? renderQueueOverride : (
int)
UnityEngine.Rendering.RenderQueue.Transparent;
728 material.renderQueue = (renderQueueOverride >= 0) ? renderQueueOverride : (
int)
UnityEngine.Rendering.RenderQueue.Transparent;
744 material.renderQueue = (renderQueueOverride >= 0) ? renderQueueOverride : (
int)
UnityEngine.Rendering.RenderQueue.Transparent;
778 material.renderQueue = (renderQueueOverride >= 0) ? renderQueueOverride : material.renderQueue;
786 return (property.floatValue != 0.0f);
791 if (material.HasProperty(propertyName))
793 return material.GetFloat(propertyName);
801 if (material.HasProperty(propertyName))
803 return material.GetVector(propertyName);
811 if (material.HasProperty(propertyName))
813 return material.GetColor(propertyName);
819 protected static void SetFloatProperty(Material material,
string keywordName,
string propertyName,
float? propertyValue)
821 if (propertyValue.HasValue)
823 if (keywordName != null)
825 if (propertyValue.Value != 0.0f)
827 material.EnableKeyword(keywordName);
831 material.DisableKeyword(keywordName);
835 material.SetFloat(propertyName, propertyValue.Value);
839 protected static void SetVectorProperty(Material material,
string propertyName, Vector4? propertyValue)
841 if (propertyValue.HasValue)
843 material.SetVector(propertyName, propertyValue.Value);
847 protected static void SetColorProperty(Material material,
string propertyName, Color? propertyValue)
849 if (propertyValue.HasValue)
851 material.SetColor(propertyName, propertyValue.Value);