But keep previous Instantiate's texture the same..?
I'm completely stumped by this, I can instance the same object with a different texture but the issues comes when it changes the previous instance's texture.
An example of what I mean is, instantiating a prefab called Chap, like: Instantiate (Chap) with a blue texture, then Instantiate (Chap) again, with a pink texture.. Make sense?
Anyone have any ideas or any links to code references that might help? Cheers.
EDIT: Sorry, I'm not being very clear I'm having trouble explaining what I mean. I have a prefab of a person, with an unlit blue texture, I want to be able to instantiate the same prefab, in a different place with a different texture.
Aha! Managed to find some code already posted here that pretty much did what I need:
answered Jun 14 '11 at 04:38 PM
Hi There! If I understand what you're saying, you want multiple instantiated objects with the same texture? That is quite possible. Here's a quick demo (requires a gameobject and 3 textures).
Here's some things to note: Each time you change the texture on a gameobject when unity is running, Unity creates a temporary instantiated material of that object. This means your changes don't go to the hard drive, and you're pretty much making each object completely seperate (think individual draw-calls if you want to use this on a phone or iPad in the future).
You can't directly access an objects material, as it is rendered through either a Mesh Renderer or Skinned Mesh Renderer (for characters). A material isn't a component, so you can't use GetComponent on it directly.
answered Jun 14 '11 at 02:34 PM