当前位置: 首页>>代码示例>>C#>>正文


C# Material.EnableKeyword方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:Maxii,项目名称:CodeEnv.Master,代码行数:32,代码来源:AElementDisplayManager.cs

示例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;
        }
    }
开发者ID:Drenerdo,项目名称:projectspark,代码行数:28,代码来源:TOD_Sky+Settings.cs

示例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;
        }
    }
开发者ID:Drenerdo,项目名称:projectspark,代码行数:28,代码来源:TOD_Sky+Settings.cs

示例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;
			}
		}
	}
开发者ID:AmaranthYan,项目名称:theArena,代码行数:27,代码来源:FocusableWeaponComponent.cs

示例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;
 }
开发者ID:xeroskiller,项目名称:Unity5Effects,代码行数:33,代码来源:MPGPLightRenderer.cs

示例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);
        }
开发者ID:Maxii,项目名称:CodeEnv.Master,代码行数:13,代码来源:UniverseCenterDisplayManager.cs

示例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;
        }
    }
开发者ID:jawa0,项目名称:JabaUnityScripts,代码行数:49,代码来源:JAShaderUtils.cs

示例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");
    }
开发者ID:VCRhythm,项目名称:hotfrog,代码行数:15,代码来源:SpriteLoad.cs

示例9: SetKeyword

 static void SetKeyword(Material m, string keyword, bool state)
 {
     if (state)
         m.EnableKeyword(keyword);
     else
         m.DisableKeyword(keyword);
 }
开发者ID:Zero-Ax,项目名称:Mouse-position-Drag,代码行数:7,代码来源:SprayUnlitMaterialEditor.cs

示例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;
     }
 }
开发者ID:SilentSupernova,项目名称:Getaway,代码行数:30,代码来源:StandardShaderCurveGUI.cs

示例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);
    }
开发者ID:rcd229,项目名称:Crystallize2D,代码行数:34,代码来源:MaterialFadeIn.cs

示例12: Start

        void Start()
        {
            material = GetComponentInChildren<Renderer>().material;
            material.EnableKeyword("_EMISSION");

            timer = 0f;
            t = 0f;
        }
开发者ID:sigmadruid,项目名称:NewMaze,代码行数:8,代码来源:Sparking.cs

示例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;
     }
 }
开发者ID:LuxoftLab,项目名称:AnatomicalMirror,代码行数:45,代码来源:AnatomicalController.cs

示例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);
     }
 }
开发者ID:NeonPandaSp,项目名称:ValenceGame,代码行数:10,代码来源:EffectBase.cs

示例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;
 }
开发者ID:DarkDecaydence,项目名称:MGAE_4D-Puzzle,代码行数:11,代码来源:ParentFourthDimensional.cs


注:本文中的UnityEngine.Material.EnableKeyword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。