Shader Texture Change

Hi, guys.

I'm making some pinball game and I have a doubt about some textures.

On the pinball table I have some objects that work as labels like "POWER", arrows and other lights. All objects have some shader and are using the same Texture Map, an image that contains all textures of all objects on the table (this was provided by my 3D modeler).

I need to change the texture of some objects when player hit some table areas. Some objects, not all objects. Is there any way to do this using a general texture map like I'm using or I need to create specified textures for each object?

Thanks!

You can use general texture maps for that. Just create a script that changes the texture whenever the instance gets hit, or whenerver you want to change the apperance. I have made a script that works quite similar. It changes textures when you hit a button.

var happyTex : Texture;
var sadTex : Texture;

function OnEnable(){
    renderer.material.mainTexture = happyTex;
}

function Update () {
    if (Input.GetKeyDown (KeyCode.U))
    {
        if (renderer.material.mainTexture == happyTex)
        {
            renderer.material.mainTexture = sadTex;
        }
        else if (renderer.material.mainTexture == sadTex)
        {
            renderer.material.mainTexture = happyTex;
        }
    }
}

The term that you want, when saying "general texture map", is atlas.

You can do this any way you like. My recommendation is to copy the UVs, from UV1, move them to UV2. Then, you can transform them as you like, but it would probably make the most sense to work with them in the islands they came in, because the modeler presumably did a good job unwrapping already. Then, when the appearances need to change, change the materials, and use custom shaders that utilize UV2 instead of UV1.

You could always just keep the same UVs, and map a new atlas to them, but if you've got an entire machine, and you're only going to make an atlas for a subset of that machine, UV1 probably isn't going to make good use of texture space - there would probably be a lot of empty area.

Thank you! This sample code help me!