car Color Changer IN GAME!

Is there a way to set the color of a car in the actual game, and not in the editor?

You can swap which material is on by using.

    public Material[] materials;

void SwapMaterial0 () {
    renderer.sharedMaterial = materials[0];

void SwapMaterial1 () {
renderer.sharedMaterial = materials[1];

and so forth.... In the inspector create your array of materials and then put each material into a slot. Then simply when you want to change which material is on that object call a function which changes the material number in the array that is being rendered. This would be useful if you had set colour blocks to pick from.

Another method would be to program your own RGBA selector which depending on mouse position on the an image of RGBA to change the RGBA code values it would require a lot more work than most people would give on this site.

private float redNumber = 1.0f;
private float greenNumber = 1.0f;
private float blueNumber = 1.0f;
private float alphaNumber = 1.0f;

renderer.material.color = new Color(redNumber, greenNumber, blueNumber, alphaNumber);


Code not tested and posted in C#, Only Snipets to be incorporated and understood into your own code. Will not work as it is.

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;


void OnGUI () {
if (GUI.Button(new Rect(15,15,100,50),“textures”))

  •  {* 
  •  	for(int i=0;i<15;i++)*
  •  	{*

g*.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