- Home /
How to update a materials' shader properties using JavaScript
I'm wanting to dynamicaly update the following properties (_Blend, _MainTex & _Texture2), as a gameObject rotates around the y axis. I'm new to Unity and wondering if its even possible from javascript?
Shader "Blend 2 Textures" { Properties { _Blend ("Blend", Range (0, 1) ) = 0.5 _MainTex ("Texture 1", 2D) = "" _Texture2 ("Texture 2", 2D) = "" }
SubShader { Pass { SetTexture[_MainTex] SetTexture[_Texture2] { ConstantColor (0,0,0, [_Blend]) Combine texture Lerp(constant) previous } } } }
Answer by Jessy · Feb 03, 2011 at 01:35 PM
_Blend: http://unity3d.com/support/documentation/ScriptReference/Material.SetFloat.html
_MainTex: http://unity3d.com/support/documentation/ScriptReference/Material-mainTexture.html
_Texture2: http://unity3d.com/support/documentation/ScriptReference/Material.SetTexture.html
Answer by ravi_gohil999 · Feb 20, 2013 at 03:08 AM
Try this plugin. 3-4 simple steps to use. You can update or load shader property on runtime.
Your answer
![](https://koobas.hobune.stream/wayback/20220613102615im_/https://answers.unity.com/themes/thub/images/avi.jpg)