Hi All
I am trying to change the Emissive Color of the Materail . I am using the below code.
public material mat;
public void Start()
{
mat.EnableKeyword("_EMISSION");
mat.SetColor("_EmisColor",,Color.red);
}
The shader of the material is Legacy Shader/transparent/vertextlit.
but the emissive color is not changed. Could any one Help me…
The manual shows it a little differently:
“”_EmissionColor" is the emissive color of a material."
1 Like
This is that shader from the unity built-in shaders:
Legacy/Transparent/VertexLit
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
Shader "Legacy Shaders/Transparent/VertexLit" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Spec Color", Color) = (1,1,1,0)
_Emission ("Emissive Color", Color) = (0,0,0,0)
_Shininess ("Shininess", Range (0.1, 1)) = 0.7
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
// Non-lightmapped
Pass {
Tags { "LightMode" = "Vertex" }
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
Lighting On
SeparateSpecular On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
// Lightmapped, encoded as dLDR
Pass {
Tags { "LightMode" = "VertexLM" }
BindChannels {
Bind "Vertex", vertex
Bind "normal", normal
Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
Bind "texcoord", texcoord1 // main uses 1st uv
}
SetTexture [unity_Lightmap] {
matrix [unity_LightmapMatrix]
constantColor [_Color]
combine texture * constant
}
SetTexture [_MainTex] {
combine texture * previous DOUBLE, texture * primary
}
}
// Lightmapped, encoded as RGBM
Pass {
Tags { "LightMode" = "VertexLMRGBM" }
BindChannels {
Bind "Vertex", vertex
Bind "normal", normal
Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
Bind "texcoord1", texcoord1 // unused
Bind "texcoord", texcoord2 // main uses 1st uv
}
SetTexture [unity_Lightmap] {
matrix [unity_LightmapMatrix]
combine texture * texture alpha DOUBLE
}
SetTexture [unity_Lightmap] {
constantColor [_Color]
combine previous * constant
}
SetTexture [_MainTex] {
combine texture * previous QUAD, texture * primary
}
}
}
}
As you can see, the property name is “_Emission”.
Thanks fire7Side & jeffreyschoch for your post… The propery name _Emission is Correct…
1 Like
I was getting this kind of error while trying to get color:

This kind of code, I have used:
Color startCol = myMaterial.GetColor("_Emission");
myMaterial.SetColor("_Emission", startCol * new Color(1f, 1f, 1f, 1f - i));
As i’m working in HDRP, not sure if it differs per pipeline, I use “_EmissiveColor” when changing the emissive color of a material.