- Home /
Change the Object texture at runtime.
Hello, I am working on my game,s multiplayer module. where i have a bike and i want to change the texture of my opponent,s bike at run time. i have just one prefab which instantiate at runtime. how do i change its texture or do i need to make an other prefab for opponent?
thanks in advance.
Answer by Arshia001 · Aug 10, 2011 at 08:10 AM
You should store a reference to the other bike's spawned (cloned) prefab, and do something like this:
other_bike.FindChild
("Name of the child gameobject for which you want to change the texture")
.renderer.material.mainTexture=other_texture;
This is assuming you want to change the texture on only one piece of the bike. You can repeat this for all the different mesh renderers on the bike.
Your answer
![](https://koobas.hobune.stream/wayback/20220612174018im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Assigning UV Map to model at runtime 0 Answers
I cant't see the texture of the other player in my multiplayer game. 1 Answer
Client-Server 1 Answer
File Input 1 Answer