#How to change material properties on a mesh with a script

2 messages · Page 1 of 1 (latest)

true ocean
#

I am working on a light, and have all the textures, normals, roughnesses... AND emission on one material on one l mesh (material is not its own unique res). The mesh is in its own unique scene with an omni directional light.

I am trying to make it so that the lights can be turned off/ on.

I connected a script to the root node of the scene, and have managed to turn off/on the omni directional light by reducing its energy to 0.

However the material emission of the lightbulb still stays and spoils the effect. How do i change the properties of the material, to either turn off emission or reduce its energy to 0?

true ocean
#

Ok, so i answered this question my self. since i could not wait...

You basically have to create two resources of the light texture, one with the emission (when on) and one without the emission (when off). save them to your game files.

In your script in the light scene, preload the texture, by referencing their path. and then when you are turning the light on/off assign the appropriate material to the material overide of the mesh.
.