Hi EveryOne,
I want to change the game object material at run time? The object should change the color what the material have like change the shader at runtime.
Thanks,
JackiM.
Hi EveryOne,
I want to change the game object material at run time? The object should change the color what the material have like change the shader at runtime.
Thanks,
JackiM.
You should try searching the forums and/or Unity Answers first. Anyway, you would want to use this:
i dont want to change the color of the material instead i want to change the material. Like imagine there are two material we have material1 is the default while running when i click the some button the material2 should be change this is only i need now.(material1 and material2 having separate color and shader).
got it?
gameObject.renderer.material= m1 (your material name)
I only linked to the documentation about the renderer’s material…You still require to use the renderer’s material. As Pradeep has given, you would assign the material to the renderer’s material.
if(GUI.Button(new Rect(0, 0, 100, 20), "material1")
{
gameObject.renderer.material = material1;
}
if(GUI.Button(new Rect(0, 30, 100, 20), "material2")
{
gameObject.renderer.material = material2;
}
Got it?
fine its working… Thanks u all…