How to change a unique shaders property

I am trying to change the texture of a Unity Shader called “Skybox/PanormicBeta” in code.

It has a Texture property called “Spherical (HDR)” and I cant seem to figure out to how to swap it out at runtime.

I have tried using “material.maintexture = newTexture;” but it doesnt seem to work.

Any help would be greatly appreciated!

Thanks!
Ben

Sorry I’m not that good myself but try sharedMaterial instead.

1 Like

You need to look into the shader code to find the texture property id, then use Material.SetTexture to change it.
Properties are usually listed at the very top and usually prefixed with an underscore.
“_MainTex” for example.

1 Like

Awesome thank you so much ThermalFusion! This was super helpful, and I learned something! :slight_smile:

For those finding this in the future, you can look at the Shader in the inspector and see the properties right there, in my case I needed “_Tex”

1 Like

Also, try clicking on the little cog in the top right of the inspector and selecting debug and you can actually inspect values within the shader without having to open it up in monodevelop.