something like this? getComponentInChildren(Renderer)?.sharedMaterial.setValues("_FadeAmount",1);
by user 263967078346653697
something like this? getComponentInChildren(Renderer)?.sharedMaterial.setValues("_FadeAmount",1);
by user 263967078346653697
you just set the property in threejs, we expose all of them directly.
Your example: myMaterials._FadeAmount = 1
so id have to have a reference of just that material?
by user 263967078346653697
You can use the sharedMaterials array as well
if you know that all those materials have that property/shader
this.gameObject.getComponentInChildren(Renderer).sharedMaterial._FadeAmount = 1
how can i get “_FadeAmount” to not throw error?
by user 263967078346653697
be recognized as the variable of that material’s shader
by user 263967078346653697
What error do you get
Property ‘_FadeAmount’ does not exist on type ‘Renderer’
by user 263967078346653697
the script doesnt event know which material im using yet
by user 263967078346653697
so it’s natural id get it
by user 263967078346653697
It doesnt exist on the renderer but on the material
woops my bad
by user 263967078346653697
Property ‘_FadeAmount’ does not exist on type ‘Material’
by user 263967078346653697
im trying like so
by user 263967078346653697
by user 263967078346653697
just as a test
by user 263967078346653697
im sorry im clueless on this
by user 263967078346653697
That’s typescript complaining since the base material type you get doesnt have / know your custom properties. So you have 3 options:
@ts-ignore
above that linesharedMaterial["_FadeAmount"]
declare type MyMaterial = {
_FadeAmount : number;
} & Material;