- Home /
How can we use two different material on a same game object at the same time?
Hi,
I want to use two different materials at the same time on a game object using C# language. I tried to use do it with an array of materials but it also applies one material at a time.I used the following code to apply the textures.
GameObject.GetComponent().sharedMaterial = material[0];
Please reply to my problem.
Ghost you need a mesh with at least two material IDs. Then you need to assign your two materials to shared$$anonymous$$aterials (plural).
yes I did that too but I am not able to access the second element of the objects's material array.
Answer by RocketFriday · Aug 26, 2017 at 08:46 AM
Click on the object, in the inspector then in Mesh Renderer. Set Size to 2.
and/or
UV map your object to define where each material will be applied.
or
set the alpha value of each material to %50
Hope this helps :)
Thankyou for the reply:) Actually I want to do it on a GUI button input so i don't know how to do that with the script.
Wait, so you have an object and you want to add in a material from a script via a GUI button?