本文整理汇总了C#中UnityEngine.Material.EnableKeyword方法的典型用法代码示例。如果您正苦于以下问题:C# Material.EnableKeyword方法的具体用法?C# Material.EnableKeyword怎么用?C# Material.EnableKeyword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Material
的用法示例。
在下文中一共展示了Material.EnableKeyword方法的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: SetColorRange
private void SetColorRange(Material material)
{
switch (ColorRange)
{
case TOD_ColorRangeType.Auto:
if (Components.Camera && Components.Camera.HDR)
{
material.EnableKeyword("HDR");
material.DisableKeyword("LDR");
}
else
{
material.DisableKeyword("HDR");
material.EnableKeyword("LDR");
}
break;
case TOD_ColorRangeType.HDR:
material.EnableKeyword("HDR");
material.DisableKeyword("LDR");
break;
case TOD_ColorRangeType.LDR:
material.DisableKeyword("HDR");
material.EnableKeyword("LDR");
break;
}
}
示例3: SetColorSpace
private void SetColorSpace(Material material)
{
switch (ColorSpace)
{
case TOD_ColorSpaceType.Auto:
if (QualitySettings.activeColorSpace == UnityEngine.ColorSpace.Linear)
{
material.EnableKeyword("LINEAR");
material.DisableKeyword("GAMMA");
}
else
{
material.DisableKeyword("LINEAR");
material.EnableKeyword("GAMMA");
}
break;
case TOD_ColorSpaceType.Linear:
material.EnableKeyword("LINEAR");
material.DisableKeyword("GAMMA");
break;
case TOD_ColorSpaceType.Gamma:
material.DisableKeyword("LINEAR");
material.EnableKeyword("GAMMA");
break;
}
}
示例4: GenerateWireframeMeshsAndMaterials
private void GenerateWireframeMeshsAndMaterials() {
foreach (MeshNMaterial subObj in subObjects) {
//添加AmazingWireframeGenerator
subObj.gameObject.AddComponent<TheAmazingWireframeGenerator>();
for (int i = 0;i < subObj.originalMaterials.Length;i++) {
Material wireframeNoTexMat = new Material(
Shader.Find("VacuumShaders/The Amazing Wireframe/Unlit/NoTex"));
wireframeNoTexMat.SetColor("_Color", subObj.originalMaterials[i].GetColor("_Color"));
wireframeNoTexMat.EnableKeyword("V_WIRE_ANTIALIASING_ON");
wireframeNoTexMat.EnableKeyword("V_WIRE_LIGHT_ON");
subObj.wireframeNoTexMaterials[i] = wireframeNoTexMat;
Material wireframeTexMat = new Material(
Shader.Find("VacuumShaders/The Amazing Wireframe/Deferred/Bumped Specular"));
wireframeTexMat.SetColor("_Color", subObj.originalMaterials[i].GetColor("_Color"));
if (subObj.originalMaterials[i].HasProperty("_SpecColor"))
wireframeTexMat.SetColor("_SpecColor", subObj.originalMaterials[i].GetColor("_SpecColor"));
if (subObj.originalMaterials[i].HasProperty("_Shininess"))
wireframeTexMat.SetFloat("_Shininess", subObj.originalMaterials[i].GetFloat("_Shininess"));
wireframeTexMat.SetTexture("_MainTex", subObj.originalMaterials[i].GetTexture("_MainTex"));
if (subObj.originalMaterials[i].HasProperty("_BumpMap"))
wireframeTexMat.SetTexture("_BumpMap", subObj.originalMaterials[i].GetTexture("_BumpMap"));
wireframeTexMat.EnableKeyword("V_WIRE_ANTIALIASING_ON");
wireframeTexMat.EnableKeyword("V_WIRE_LIGHT_ON");
subObj.wireframeTexMaterials[i] = wireframeTexMat;
}
}
}
示例5: CloneMaterial
public override Material CloneMaterial(Material src, int nth)
{
Material m = new Material(src);
m.SetInt("g_batch_begin", nth * m_instances_par_batch);
m.SetBuffer("particles", m_world.GetParticleBuffer());
if (m_hdr)
{
m.SetInt("_SrcBlend", (int)BlendMode.One);
m.SetInt("_DstBlend", (int)BlendMode.One);
}
else
{
m.SetInt("_SrcBlend", (int)BlendMode.DstColor);
m.SetInt("_DstBlend", (int)BlendMode.Zero);
}
if(m_enable_shadow)
{
m.EnableKeyword("ENABLE_SHADOW");
switch (m_sample)
{
case Sample.Fast:
m.EnableKeyword("QUALITY_FAST");
break;
case Sample.Medium:
m.EnableKeyword("QUALITY_MEDIUM");
break;
case Sample.High:
m.EnableKeyword("QUALITY_HIGH");
break;
}
}
return m;
}
示例6: 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);
}
示例7: SetMaterialRenderingMode
public static void SetMaterialRenderingMode(Material material, StandardShaderRenderingMode mode)
{
switch (mode)
{
case StandardShaderRenderingMode.Opaque:
material.SetOverrideTag("RenderType", "");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = -1;
break;
case StandardShaderRenderingMode.Cutout:
material.SetOverrideTag("RenderType", "TransparentCutout");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.EnableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 2450;
break;
case StandardShaderRenderingMode.Fade:
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
break;
case StandardShaderRenderingMode.Transparent:
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
break;
}
}
示例8: MakeMaterial
private Material MakeMaterial()
{
Material newMaterial = new Material(Shader.Find("Standard"));
newMaterial.SetFloat("_Mode", 1.0f);
newMaterial.EnableKeyword("_ALPHATEST_ON");
newMaterial.EnableKeyword("_NORMALMAP");
newMaterial.SetTexture("_BumpMap", AssetDatabase.LoadAssetAtPath<Texture>("Assets/Sprites/Frogs/" + referencePath + "/Processed/" + referencePath.Replace(" ", "") + spriteName + "_NORMALS.png"));
//newMaterial.SetTexture("_SpecGlossMap", AssetDatabase.LoadAssetAtPath<Texture>("Assets/Sprites/Frogs/" + referencePath + "/Processed/" + referencePath.Replace(" ", "") + spriteName + "_SPECULAR.png"));
newMaterial.SetTexture("_ParallaxMap", AssetDatabase.LoadAssetAtPath<Texture>("Assets/Sprites/Frogs/" + referencePath + "/Processed/" + referencePath.Replace(" ", "") + spriteName + "_DEPTH.png"));
newMaterial.SetTexture("_OcclusionMap", AssetDatabase.LoadAssetAtPath<Texture>("Assets/Sprites/Frogs/" + referencePath + "/Processed/" + referencePath.Replace(" ", "") + spriteName + "_OCCLUSION.png"));
newMaterial.SetFloat("_Glossiness", 0);
AssetDatabase.CreateAsset(newMaterial, "Assets/Sprites/Frogs/" + referencePath + "/" + referencePath.Replace(" ", "") + spriteName + ".mat");
return AssetDatabase.LoadAssetAtPath<Material>("Assets/Sprites/Frogs/" + referencePath + "/" + referencePath.Replace(" ", "") + spriteName + ".mat");
}
示例9: SetKeyword
static void SetKeyword(Material m, string keyword, bool state)
{
if (state)
m.EnableKeyword(keyword);
else
m.DisableKeyword(keyword);
}
示例10: SetupMaterialWithBlendMode
public static void SetupMaterialWithBlendMode(Material material, BlendMode blendMode)
{
switch (blendMode)
{
case BlendMode.Opaque:
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.renderQueue = -1;
break;
case BlendMode.Cutout:
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.EnableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.renderQueue = 2450;
break;
case BlendMode.Transparent:
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.renderQueue = 3000;
break;
}
}
示例11: Start
IEnumerator Start()
{
foreach (var r in GetComponentsInChildren<Renderer>()) {
renderers.Add(r);
originalMaterials[r] = r.sharedMaterial;
var material = new Material(r.material);
material.SetFloat("_Mode", 2);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
r.material = material;
}
for (float t = 0; t < 1f; t += Time.deltaTime) {
if (!UpdateRenderers(t)) {
yield break;
}
yield return null;
}
foreach (var r in renderers) {
if (r) {
r.material = originalMaterials[r];
}
}
Destroy(this);
}
示例12: Start
void Start()
{
material = GetComponentInChildren<Renderer>().material;
material.EnableKeyword("_EMISSION");
timer = 0f;
t = 0f;
}
示例13: SetShaderBlendMode
public static void SetShaderBlendMode(BlendMode blendMode, ref Material material)
{
switch (blendMode) {
case BlendMode.Opaque:
material.SetFloat("_Mode", (float)BlendMode.Opaque);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = -1;
break;
case BlendMode.Cutout:
material.SetFloat("_Mode", (float)BlendMode.Cutout);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.EnableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 2450;
break;
case BlendMode.Fade:
material.SetFloat("_Mode", (float)BlendMode.Fade);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.EnableKeyword("_ALPHABLEND_ON");
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
break;
case BlendMode.Transparent:
material.SetFloat("_Mode", (float)BlendMode.Transparent);
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHATEST_ON");
material.DisableKeyword("_ALPHABLEND_ON");
material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
break;
}
}
示例14: EnsureKeyword
public void EnsureKeyword(Material material, string name, bool enabled)
{
if (enabled != material.IsKeywordEnabled(name))
{
if (enabled)
material.EnableKeyword(name);
else
material.DisableKeyword(name);
}
}
示例15: setMaterialToFade
private void setMaterialToFade(Material m)
{
m.SetFloat("_Mode", 2);
m.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
m.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
m.SetInt("_ZWrite", 0);
m.DisableKeyword("_ALPHATEST_ON");
m.EnableKeyword("_ALPHABLEND_ON");
m.DisableKeyword("_ALPHAPREMULTIPLY_ON");
m.renderQueue = 3000;
}