Hi !
I create a new shader and try to manipulate constants using a script.
Unfortunately, I got this error when I launch the project :
‘#sprite’ does not have any property called ‘mouse’
I must miss something but I can’t figure what.
Thanks for your help !
What I have done :
-
copy files .fp, .vp, .material from materials/sprite in a new folder
-
rename files
-
open the new material and select new VP and FP files. Then add 3 new constants
-
add simple FP code to test
varying mediump vec2 var_texcoord0;
uniform lowp sampler2D texture_sampler;
uniform lowp vec4 mouse;
void main()
{
vec2 mouse = vec2(mouse.x, mouse.y);
gl_FragColor = vec4(var_texcoord0.xy, 0.0, 1.0);
}
- created a new script
function init(self)
go.set(“#sprite”, “mouse”, vmath.vector4(150.0, 150.0, 0, 0))
end
- in the collection, add a new GameObject and attach a Sprite (id = sprite) and the Script
- change the Sprite Material’s property to attach the material file