Best way to make a material transparent using a script
I can't seem to find a straightforward way to set the alpha of a material I have assigned to an object 0, so it appears transparent if certain conditions are true. Right now I'm using a hacky solution, changing the blend mode to colored glass. Any ideas? I'm tired of digging through documentation to find an answer to something that should be so simple.
Here is what I have so far:
//@input Component.MeshVisual selector
if (globalIndex == 0) {
script.selector.mainPass.blendMode = 6;
}
if (globalIndex == 1) {
script.selector.mainPass.blendMode = 1;
}
It depends on your material. If it is one of the Lens Studio default materials you can adjust the base color. If it is a custom material, you'll need to make sure you have a float parameter exposed that controls the opacity. There's a scripting example on this page that should help point you in the right direction (I'm using Asset.Material instead of Component.MeshVisual in this example): https://arbootcamp.com/snapchat-intermediate/opacity-slider#material-opacity