Switching Texture in runtime

Let's say we have 3D object with the TPHelper script attached

 

Let's create the Controller script with public helper filed:

public TPHelper helper;

 

And drag and drop our 3D object to this helper filed

To switch texture from the same atlas we can use:

helper.OnTextureChange("t_share");
helper.OnTextureChange("b_share");

 

If we need to switch texture from another atlas, we also need to switch object atlas as well before applying new texture name:

if(!helper.atlasPath.Equals(AtlasPath2))  {
	helper.SwitchAtlas(AtlasPath2);
}
			
helper.OnTextureChange("fireball_0001");

 

The full example can be found under the RuntimeAtlasTextureSwitch example scene.