As I instantiate car 3d model in the game, I have provide functionality to change car color as per game play choice. But this is not working because 3d model creating own instance of the material.
You can see this in the following image:
I have created separate material for this purpose and changing its color but run time it didn’t get affected. If I close the game and then start again then my car getting last given color but not on the spot.
Before it was working properly when I was implemented but today it’s not working. Give me suggestion for this so I can change my car color at run time.
yes, material is assigned when its in prefab form and to color changing script too. As gameobject instantiated within game, it’s creating new instance of all materials - that you can clearly see in above my message image.
When I click on color change button its changing color of assigned material but car gameobject created its own material so this change not get affected.
I am just creating material normal way and assign it to car gameobject and a script that changing its color.
I don’t know anything about shared material.
If when you are instantiating the mesh it is automatically creating instances of its materials as well, then modifying the original materials will have zero impact because they are no longer connected to the original materials in any way. Material “instances” in Unity are really just copies with the material’s name appended with “(Instance)”. You need to be modifying those new materials on the mesh if you want to change the colors, not the materials you have in your array.
I have created new material specially for changing car chassis color and assigned this to the script and car mesh renderer. But after instantiating mesh renderer creating instance of it.
what I should do in this case? I want to change car color based on the selection.
Before it was working properly, recently Unity did any kind of changes in Unity related to this!!
I want to stop that new instance creation for the material, any way exist for this?