Export the Shader attribute in the Unity3d Editor, unity3dshader
This example is used to export the texture and zoom of the shader of TerrainForMobile/3 TexturesDiffuseSimple.
Protected const string SHADER_FILTER = "TerrainForMobile/3 TextureDiffuseSimple"; public void parse (GameObject go) {// if it is null, Renderer renderer = go is not written. renderer; Material mat = renderer. sharedMaterial; Shader shader = mat. shader; int count = ShaderUtil. getPropertyCount (shader); for (int index = 0; index <count; ++ index) {ShaderUtil. shaderPropertyType = ShaderUtil. getPropertyType (shader, index); string propertyName = ShaderUtil. getPropertyName (shader, index); if (ShaderUtil. shaderPropertyType. texEnv = type) {Debug. log ("ShaderPropertyName:" + propertyName); Texture texture = mat. getTexture (propertyName); Debug. log ("ShaderPropertyName:" + texture. toString (); Vector2 textureScale = mat. getTextureScale (propertyName); Debug. log ("textureScale:" + textureScale. toString (); Vector2 textureOffset = mat. getTextureScale (propertyName); Debug. log ("textureOffset:" + textureOffset. toString ();} else if (ShaderUtil. shaderPropertyType. color = type ){}}}
How does unity3d code change the color of a shader?
Some Material does not have the Color attribute.
When selecting the Shader, you must check whether the color attribute can be modified in the monitoring panel. If you can modify the color attribute, you can use renderer. material. color = color to modify the color.
Equivalent to renderer. material. SetColor ("_ Color", Color );
Some of them cannot be changed directly through the panel debugging assignment.
When you obtain the Color, the following error occurs: "_ Color" cannot be found. However, you can change the Color of the material ball in the Inspection Panel, for example:
You can use renderer. material. SetColor ("_ TintColor", color); to modify.
The first parameter specifies the variable name to be modified. The variable name is determined based on TintColor in the lower-left corner. An English underline is added before the variable name.
In unity3d, how does one use js Code to change the three sub-pasters In the shader?
Use SetColor () function
For more information, see the Material Class in the official script manual.
Example:
Function Start (){
// Set the glossy color to use the highlighted color.
Renderer. material. shader = Shader. Find ("Glossy ");
// Set the highlight to red.
Renderer. material. SetColor ("_ SpecColor", Color. red );
}