- Home /
Vehicle color select?
Hi. We're developing a racing game right now and something we feel to be an obvious feature is the ability to choose what colour your car should have. What I've been able to find so far has been the possibility of changing the colour of a whole material, but I'm after the ability to change the tint of specific parts of the texture. Essentially meaning that parts of the vehicle will be completely unchanged by my colour selections, while others are. The results should be like in the following picture:
As you can see, the two cars on the left are the same model, bot the green part on the top car has been replaced with red on the bottom one, while the yellow parts, taillights and other details in the texture remain unchanged. This is what I want to acheive. Anyone know how?
wouldn't it be easier if you would just call another texture on selection of the color? So you only change the texture on the material.Just make the whole car's body with one texture using uvw mapping and it will make things easier for you!So in this way create as much as textures with different colors with the parts of the body and just create an array that will hold all these textures then try to assign them on the selection
hey @Hogge sir could you please tell me the script for changing vehicle color on gui button click as you have already done it.
i am stuck on that for almost 3 days.
i can change the color of a single surface like door or hood and i can also change the color of the car by keypresS BUT I CAN'T DO IT BY GUI BUTTON CLIC$$anonymous$$.
I WOULD REALLY APPRECIATE YOUR HELP.THAN$$anonymous$$ YOU
Answer by haim96 · Nov 24, 2013 at 12:31 PM
check this one:
https://www.assetstore.unity3d.com/#/content/2253
but i'm not sure if this editable texture in run time...
this tutorial page say it should be possible:
Seems promising. I'll ask our programmer to check it out :)
yap, you can also change decals etc... which is cool. you can get endless option for coloring and customization options.
if you found my answer helpful please close the question. thanks!
Answer by deadshot · Oct 20, 2014 at 10:21 AM
using UnityEngine;
using System.Collections;
public class texturechange : MonoBehaviour {
public Texture[] Tex ;
public GameObject[] g=new GameObject[15];
int maxTextures;
int arrayPos = 0;
//private int i=0;
void Start ()
{
maxTextures = Tex.Length-1;
//g.renderer.material.mainTexture=tex[i];
}
void OnGUI () {
if (GUI.Button(new Rect(15,15,100,50),"textures"))
{
for(int i=0;i<15;i++)
{
g[i].renderer.material.mainTexture = Tex[arrayPos];
}
if(arrayPos == maxTextures)
{
arrayPos = 0;
}
else
{
arrayPos++;
}
}
}
}
make a dynamic array of surfaces of which you want to change the texture then apply the texture . you can also change the material in the same way