I’m sorry if this question has been answered already somewhere, but I’ve done some searching and I can’t find an answer that helps me.
My player model is a cube with a plane inside of it. Both shapes have different materials on them, and I want to change the material on only the plane of the model during run-time.
How can I do this?
Declare first
var plane: GameObject;
var planeTex: Texture;
Just drag and drop plane and textures as public parameters from unity scene.
In runtime code, give
plane.renderer.material.mainTexture = planeTex;
Hope this help you.
DaveA
2
Get the plane gameobject, then access gameObject.renderer.material Unity - Scripting API: Renderer.material