本文整理汇总了C#中UnityEngine.Material.IsKeywordEnabled方法的典型用法代码示例。如果您正苦于以下问题:C# Material.IsKeywordEnabled方法的具体用法?C# Material.IsKeywordEnabled怎么用?C# Material.IsKeywordEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Material
的用法示例。
在下文中一共展示了Material.IsKeywordEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializePrimaryMeshMaterial
/// <summary>
/// Initializes the primary mesh material.
/// Note: for good explanation of Renderer.materials see http://answers.unity3d.com/questions/228744/material-versus-shared-material.html
/// </summary>
/// <param name="material">The material.</param>
private void InitializePrimaryMeshMaterial(Material material) {
if (!material.IsKeywordEnabled(UnityConstants.StdShader_RenderModeKeyword_FadeTransparency)) {
material.EnableKeyword(UnityConstants.StdShader_RenderModeKeyword_FadeTransparency);
}
if (!material.IsKeywordEnabled(UnityConstants.StdShader_MapKeyword_Metallic)) {
material.EnableKeyword(UnityConstants.StdShader_MapKeyword_Metallic);
}
/*******************************************************************************************
* These values were set when I wasn't using the metal material's MetallicMap, opting
* instead to set these. UNCLEAR Why I don't know, but not using the MatallicMap kept the
* colors from showing up on the element unless the shader tab was clicked in the inspector.
*
* if (material.GetFloat(UnityConstants.StdShader_Property_MetallicFloat) != 0.25F) {
* material.SetFloat(UnityConstants.StdShader_Property_MetallicFloat, 0.25F);
* }
* if (material.GetFloat(UnityConstants.StdShader_Property_SmoothnessFloat) != 0.4F) {
* material.SetFloat(UnityConstants.StdShader_Property_SmoothnessFloat, 0.4F);
* }
*******************************************************************************************/
if (!material.IsKeywordEnabled(UnityConstants.StdShader_MapKeyword_Normal)) {
material.EnableKeyword(UnityConstants.StdShader_MapKeyword_Normal);
}
if (material.GetFloat(UnityConstants.StdShader_Property_NormalScaleFloat) != 1.25F) {
material.SetFloat(UnityConstants.StdShader_Property_NormalScaleFloat, 1.25F);
}
}
示例2: InitializePrimaryMeshMaterial
private void InitializePrimaryMeshMaterial(Material material) {
// no need to enable RenderingMode.Opaque as it is the default // for now, color is green
if (material.IsKeywordEnabled(UnityConstants.StdShader_MapKeyword_Metallic)) {
material.EnableKeyword(UnityConstants.StdShader_MapKeyword_Metallic);
}
material.SetFloat(UnityConstants.StdShader_Property_MetallicFloat, Constants.ZeroF);
material.SetFloat(UnityConstants.StdShader_Property_SmoothnessFloat, 0.20F);
if (!material.IsKeywordEnabled(UnityConstants.StdShader_MapKeyword_Normal)) {
material.EnableKeyword(UnityConstants.StdShader_MapKeyword_Normal);
}
material.SetFloat(UnityConstants.StdShader_Property_NormalScaleFloat, 1F);
}
示例3: FindProperties
public void FindProperties(Material material, MaterialProperty[] props)
{
m_LightingMode = FindProperty ("_LightingMode", props, false);
m_BlendMode = FindProperty ("_BlendMode", props, false);
m_AlphaMode = FindProperty ("_AlphaMode", props, false);
m_MainTexture = FindProperty ("_MainTex", props);
m_TintColor = FindProperty ("_TintColor", props);
m_Cutoff = FindProperty ("_Cutoff", props, false);
m_Thickness = FindProperty ("_Thickness", props, false);
m_InvFade = FindProperty ("_InvFade", props, false);
m_DistanceFadeStart = FindProperty ("_FadeStart", props, false);
m_DistanceFadeEnd = FindProperty ("_FadeEnd", props, false);
m_SoftParticles = material.IsKeywordEnabled ("SOFTPARTICLE_ON") ? true : false;
m_DistanceFade = material.IsKeywordEnabled ("DISTANCEFADE_ON") ? true : false;
}
示例4: EnsureKeyword
public void EnsureKeyword(Material material, string name, bool enabled)
{
if (enabled != material.IsKeywordEnabled(name))
{
if (enabled)
material.EnableKeyword(name);
else
material.DisableKeyword(name);
}
}
示例5: UseMeshNormalsCheckbox
bool UseMeshNormalsCheckbox (Material material) {
EditorGUI.BeginChangeCheck();
bool fixedNormals = material.IsKeywordEnabled(_FIXED_NORMALS);
bool fixedNormalsBackRendering = material.IsKeywordEnabled(_FIXED_NORMALS_BACK_RENDERING);
bool meshNormals = EditorGUILayout.Toggle(new GUIContent("Use Mesh Normals", "If this is unticked, a Fixed Normal value will be used instead of the vertex normals on the mesh. Using a fixed normal is better for performance and can result in better looking lighting effects on 2d objects."),
!fixedNormals && !fixedNormalsBackRendering);
if (EditorGUI.EndChangeCheck()) {
SetKeyword(material, _FIXED_NORMALS, meshNormals ? false : fixedNormalsBackRendering ? false : true);
SetKeyword(material, _FIXED_NORMALS_BACK_RENDERING, meshNormals ? false : fixedNormalsBackRendering);
}
return meshNormals;
}
示例6: ShaderPropertiesGUI
protected virtual void ShaderPropertiesGUI (Material material) {
using (new EditorGUILayout.HorizontalScope()) {
GUILayout.FlexibleSpace();
var showAdvancedLabel = new GUIContent("Show Advanced", "Show extra options under all sections. This only affects the inspector. The Material's resulting shader is still compiled/optimized based on what features you actually use and don't use.");
float lw = GUI.skin.toggle.CalcSize(showAdvancedLabel).x;
EditorGUIUtility.labelWidth = lw;
showAdvanced = EditorGUILayout.Toggle(showAdvancedLabel, showAdvanced);
EditorGUIUtility.labelWidth = 0f;
}
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
{
LightingModePopup();
BlendModePopup();
if (showAdvanced) {
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
int renderQueue = EditorGUILayout.IntSlider("Renderer Queue Offset", (int)_renderQueue.floatValue, 0, 49);
if (EditorGUI.EndChangeCheck()) material.SetInt("_RenderQueue", renderQueue);
EditorGUI.BeginChangeCheck();
eCulling culling = (eCulling)Mathf.RoundToInt(_culling.floatValue);
culling = (eCulling)EditorGUILayout.EnumPopup("Culling", culling);
if (EditorGUI.EndChangeCheck()) material.SetInt("_Cull", (int)culling);
EditorGUI.BeginChangeCheck();
bool fog = EditorGUILayout.Toggle("Use fog", material.IsKeywordEnabled("_FOG"));
if (EditorGUI.EndChangeCheck()) SetKeyword(material, "_FOG", fog);
EditorGUI.BeginChangeCheck();
bool enabled = EditorGUILayout.Toggle(
new GUIContent(
"Use Spherical Harmonics",
"Enable to use spherical harmonics to calculate ambient light / light probes. In vertex-lit mode this will be approximated from scenes ambient trilight settings."),
material.IsKeywordEnabled(_SPHERICAL_HARMONICS)
);
if (EditorGUI.EndChangeCheck())
SetKeyword(material, _SPHERICAL_HARMONICS, enabled);
}
using (new SpineInspectorUtility.BoxScope())
RenderTextureProperties("Main Maps", material);
if (showAdvanced) {
using (new SpineInspectorUtility.BoxScope()) {
Heading("Depth and Cast Shadow");
EditorGUI.BeginChangeCheck();
bool writeTodepth = EditorGUILayout.Toggle(new GUIContent("Write to Depth", "Write to Depth Buffer by clipping alpha."), _writeToDepth.floatValue != 0.0f);
if (EditorGUI.EndChangeCheck())
material.SetInt("_ZWrite", writeTodepth ? 1 : 0);
if (writeTodepth)
_materialEditor.RangeProperty(_depthAlphaCutoff, "Depth Alpha Cutoff");
EditorGUILayout.Space();
_materialEditor.RangeProperty(_shadowAlphaCutoff, "Shadow Alpha Cutoff");
}
if (_fixedNormal != null) {
using (new SpineInspectorUtility.BoxScope()) {
Heading("Normals");
bool meshNormals = UseMeshNormalsCheckbox(material);
if (!meshNormals) {
Vector3 normal;
EditorGUI.BeginChangeCheck();
normal = showAdvanced ? EditorGUILayout.Vector3Field(new GUIContent("Fixed Normal", "Defined in Camera Space. Should normally be (0,0,-1)."), _fixedNormal.vectorValue) : (Vector3)_fixedNormal.vectorValue;
if (EditorGUI.EndChangeCheck())
_fixedNormal.vectorValue = new Vector4(normal.x, normal.y, normal.z, 1.0f);
bool backRendering;
EditorGUI.BeginChangeCheck();
if (showAdvanced) {
backRendering = EditorGUILayout.Toggle(new GUIContent("Fixed Normal Back Rendering", "Tick only if you are going to rotate the sprite to face away from the camera, the fixed normal will be flipped to compensate."),
material.IsKeywordEnabled(_FIXED_NORMALS_BACK_RENDERING));
} else {
backRendering = material.IsKeywordEnabled(_FIXED_NORMALS_BACK_RENDERING);
}
if (EditorGUI.EndChangeCheck()) {
SetKeyword(material, _FIXED_NORMALS_BACK_RENDERING, backRendering);
SetKeyword(material, _FIXED_NORMALS, !backRendering);
}
}
}
}
} else {
using (new SpineInspectorUtility.BoxScope()) {
EditorGUI.BeginChangeCheck();
bool writeTodepth = EditorGUILayout.Toggle(new GUIContent("Write to Depth", "Write to Depth Buffer by clipping alpha."), _writeToDepth.floatValue != 0.0f);
if (EditorGUI.EndChangeCheck())
material.SetInt("_ZWrite", writeTodepth ? 1 : 0);
if (_fixedNormal != null)
UseMeshNormalsCheckbox(material);
}
}
//.........这里部分代码省略.........
示例7: DoDissolveArea
public virtual void DoDissolveArea(Material material)
{
m_MaterialEditor.TexturePropertySingleLine(Styles.dissolveMapText, dissolveMap);
ShowDissolveMap(material);
m_MaterialEditor.TexturePropertySingleLine(Styles.directionMapText, directionMap);
if (substituteMap != null) {
m_MaterialEditor.TexturePropertySingleLine(Styles.substituteText, substituteMap);
}
if (substituteColor != null) {
m_MaterialEditor.ColorProperty(substituteColor, Styles.substituteColorText.text);
}
m_MaterialEditor.ShaderProperty(dissolveGlow, Styles.burnInText.text);
if (material.IsKeywordEnabled("_DISSOLVEGLOW_ON")) {
if (glowFollow != null) {
m_MaterialEditor.ShaderProperty(glowFollow, Styles.glowFollowText.text);
}
m_MaterialEditor.ColorProperty(glowColor, Styles.burnColorText.text);
m_MaterialEditor.FloatProperty(glowIntensity, Styles.burnIntensity.text);
}
if (!material.IsKeywordEnabled("_EDGECOLORRAMP_USE")) {
m_MaterialEditor.ShaderProperty(colorBlend, Styles.blendColorsText.text);
m_MaterialEditor.ColorProperty(outerEdgeColor, Styles.outerEdgeText.text);
if (!material.IsKeywordEnabled("_COLORBLENDING_ON")) {
m_MaterialEditor.ShaderProperty(outerEdgeThickness, Styles.edgeThicknessText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel+1);
}
m_MaterialEditor.ColorProperty(innerEdgeColor, Styles.innerEdgeText.text);
if (!material.IsKeywordEnabled("_COLORBLENDING_ON")) {
m_MaterialEditor.ShaderProperty(innerEdgeThickness, Styles.edgeThicknessText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel+1);
} else {
m_MaterialEditor.ShaderProperty(innerEdgeThickness, Styles.edgeThicknessSoloText.text);
}
} else {
m_MaterialEditor.TexturePropertySingleLine(Styles.edgeColorRampText, edgeColorRamp);
m_MaterialEditor.ShaderProperty(innerEdgeThickness, Styles.edgeThicknessSoloText.text);
}
EditorGUILayout.Space();
EditorGUI.indentLevel++;
m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, Styles.advancedSettings);
if (m_AdvancedSettings) {
EditorGUI.indentLevel++;
EditorGUILayout.Space();
DoAdvancedArea(material);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}
示例8: InitializePrimaryMeshMaterial
private void InitializePrimaryMeshMaterial(Material material) {
if (!material.IsKeywordEnabled(UnityConstants.StdShader_RenderModeKeyword_CutoutTransparency)) {
material.EnableKeyword(UnityConstants.StdShader_RenderModeKeyword_CutoutTransparency);
}
material.SetFloat(UnityConstants.StdShader_Property_AlphaCutoffFloat, 0.2F);
}
示例9: SetKeyword
void SetKeyword(Material m, bool state, string name)
{
if (state == m.IsKeywordEnabled(name))
return;
if (state)
m.EnableKeyword(name);
else
m.DisableKeyword(name);
}
示例10: HasValidEmissiveKeyword
bool HasValidEmissiveKeyword(Material material)
{
// Material animation might be out of sync with the material keyword.
// So if the emission support is disabled on the material, but the property blocks have a value that requires it, then we need to show a warning.
// (note: (Renderer MaterialPropertyBlock applies its values to emissionColorForRendering))
bool hasEmissionKeyword = material.IsKeywordEnabled ("_EMISSION");
if (!hasEmissionKeyword && ShouldEmissionBeEnabled (emissionColorForRendering.colorValue))
return false;
else
return true;
}
示例11: ToggleHeadingKeyword
static bool ToggleHeadingKeyword (string label, Material material, string keyword) {
int i = EditorGUI.indentLevel;
var o = EditorStyles.label.fontStyle;
EditorGUI.indentLevel = 0;
EditorStyles.label.fontStyle = FontStyle.Bold;
EditorGUI.BeginChangeCheck();
bool r = EditorGUILayout.Toggle(new GUIContent(label, string.Format("This checkbox sets shader keyword: '{0}', which causes the Material to use extra shader features.", keyword)), material.IsKeywordEnabled(keyword));
if (EditorGUI.EndChangeCheck())
SetKeyword(material, keyword, r);
EditorStyles.label.fontStyle = o;
EditorGUI.indentLevel = i;
return r;
}
示例12: InitializePrimaryMeshMaterial
private void InitializePrimaryMeshMaterial(Material material) {
if (material.IsKeywordEnabled(UnityConstants.StdShader_RenderModeKeyword_FadeTransparency)) {
material.EnableKeyword(UnityConstants.StdShader_RenderModeKeyword_FadeTransparency);
}
}
示例13: HasValidEmissiveKeyword
private bool HasValidEmissiveKeyword(Material material)
{
return material.IsKeywordEnabled("_EMISSION") || !StandardShaderGUI.ShouldEmissionBeEnabled(this.emissionColorForRendering.colorValue);
}
示例14: SetMaterialKeywords
static void SetMaterialKeywords(Material material, WorkflowMode workflowMode)
{
// Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
// (MaterialProperty value might come from renderer material property block)
SetKeyword (material, "_NORMALMAP", material.GetTexture ("_BumpMap") || material.GetTexture ("_DetailNormalMap"));
SetKeyword (material, "_SUBMAP", material.GetTexture ("_SubTex"));
SetKeyword (material, "_DISSOLVEMAP", material.GetTexture ("_DissolveMap"));// || material.IsKeywordEnabled("_PAINT_ON"));
SetKeyword (material, "_DIRECTIONMAP", material.GetTexture ("_DirectionMap"));
if (workflowMode == WorkflowMode.Specular)
SetKeyword (material, "_SPECGLOSSMAP", material.GetTexture ("_SpecGlossMap"));
else if (workflowMode == WorkflowMode.Metallic)
SetKeyword (material, "_METALLICGLOSSMAP", material.GetTexture ("_MetallicGlossMap"));
SetKeyword (material, "_PARALLAXMAP", material.GetTexture ("_ParallaxMap"));
SetKeyword (material, "_DETAIL_MULX2", material.GetTexture ("_DetailAlbedoMap") || material.GetTexture ("_DetailNormalMap"));
bool shouldEmissionBeEnabled = ShouldEmissionBeEnabled (material.GetColor("_EmissionColor")) || material.IsKeywordEnabled("_DISSOLVEGLOW_ON") || material.IsKeywordEnabled("_EDGEGLOW_ON");
SetKeyword (material, "_EMISSION", shouldEmissionBeEnabled);
// Setup lightmap emissive flags
MaterialGlobalIlluminationFlags flags = material.globalIlluminationFlags;
if ((flags & (MaterialGlobalIlluminationFlags.BakedEmissive | MaterialGlobalIlluminationFlags.RealtimeEmissive)) != 0)
{
flags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
if (!shouldEmissionBeEnabled)
flags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
material.globalIlluminationFlags = flags;
}
}
示例15: SetRenderQueue
static void SetRenderQueue (Material material, string queue) {
bool meshNormal = true;
if (material.HasProperty("_FixedNormal")) {
bool fixedNormals = material.IsKeywordEnabled(_FIXED_NORMALS);
bool fixedNormalsBackRendering = material.IsKeywordEnabled(_FIXED_NORMALS_BACK_RENDERING);
meshNormal = !fixedNormals && !fixedNormalsBackRendering;
}
material.SetOverrideTag("RenderType", meshNormal ? queue : "Sprite");
}