- Home /
Car colour problem
Hello!
Recently I tried adding different colours to my cars, but to my disappointment it ended in the game crashing.
I tried activating the cars and carbodies with playerprefs, but the game crashed on Awake. When I removed all but one carbody the carshing ended.
How would YOU add the different colour options to the game?
Answer by HarshadK · Mar 20, 2015 at 09:46 AM
A simple way would be that you can get the reference to the material on carBody01 game object and set the color from code itself.
But if you are using different textures for each of these colors and there is different UV mapping for each of these textures then you can create prefab for each of these carBody01Orange, Black, and other game objects. Then at the start instantiate the required prefab as per the color required. This way you can have only one carBody01 gameobject.
Never knew that you can change the material from the code! How exactly?
Read this to change material color: $$anonymous$$aterial.color And to change material: Renderer.material
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
increase playerprefs 1 Answer
PlayerPrefs - Can I save more than one? 1 Answer
UI Slider, Save Values and Change Them 0 Answers