Is it possible to fade between textures on a 3D object?

I know you can have multiple textures on a 3D object but I’m not entirely sure how to access them. I have been using mainTexture but how do I access the others?

Basically, what I want to do is have a load of textures on a certain object and when the game stage changes, fade the alpha down one one and up on another, so that I’m basically fading between graphics. I can work that bit out… just how does one access the different textures? It’s probably something really simple but any help greatly appreciated.


EDIT: Just had a brainwave that it’s probably just like any other array… will try now.

You need to write a custom shader for this. The shader in Erics answer here might by a good start :wink:

What texture properties are available depends only on the shader you use. Usually the main texture property is called “_MainTex”, see the ShaderLab documentation for more details.

To set a texture for a material / shader at runtime you have to use Material.SetTexture. The property mainTexture is just a simplification like this:

// C# (decompiled from UnityEngine.dll)
public Texture mainTexture
        return this.GetTexture("_MainTex");
        this.SetTexture("_MainTex", value);

Like start() uses a texture. Over time reduce alpha channel to 0, then when at 0 import a new texture then raise the alpha channel back to normal. Simple fade out and fade in with new material.

  • not sure if alpha or transparency. I don’t know textures or anything like that.

You could also store the textures as array or just individuality, like startTexture, fadeInTexture