In a scene Multiple different gameobject (almost 30 kinds of gameobject) with parent child relationship. At run time (by selecting on gui button) I want to change the texture of each clicked gameobject. As user click specific gameobject a gui with multiple texture button will appear. By clicking on button that specific texture will be applied.

what is the smarter way??

Do I need to apply script to every object or else?

I have tried to apply script with some specific code it working but not regularly and correclty. further I want different texture option for each kind of gameobject

share|improve this question
    
The thing to be careful of is that while you can directly modify a material's main texture (among other properties) doing so causes that material to be cloned as a new instance. Unique material instances (which includes two clones that are identical, but separate references) cannot be batched which leads to more draw calls and lower performance. You'd be better off having your gui-object create the clone and instance properties and apply it to the mesh.material field of each object clicked on so that they all share the same material instance (and then reuse these materials as best possible). – Draco18s Jan 26 at 21:06

If this should be a general possibility to change textures of objects dynamically, then I don't suggest to use a script on each object.

May think of building ur own component, that loads a texture and looks every draw if has to change the texture.

If this should only be for a few objects, about 1-10 in ur scene it's totally ok if u want a quick'n dirty solution to aplly a script to every object.

Having a script on each object, will not affect performance dramaticly. But it is not the best practical use of a script. A script is supposed to define features, skills and movement, u want to apply to few objects, that don't behave general. So for general purpose u use components or even hard code it in ur routines, and for special cases u use a script.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.