Export the Shader attribute in the Unity3d Editor, unity3dshader

Source: Internet
Author: User

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 );
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.