ᴀʀᴍᴀɴ
ᴀʀᴍᴀɴ

Reputation: 4528

Duplicate a gameobject in right way Unity 5

I have a game object named Bolt with for example white texture , when I duplicate that and rename duplicate into EnemyBolt and change texture to orange the Bolt texture is changing into orange too , how can I copy or duplicate a gameObject that dosen't change its reference?

Upvotes: 2

Views: 1640

Answers (1)

Everts
Everts

Reputation: 10701

When you duplicate a GameObject, you also duplicate all the components that are attached to it. This way the new object gets its own set of component instances. This is in Hierarchy panel representing the content of the scene.

The Project panel represents the assets to be used in the different scenes. When you drag a material to a Renderer, that renderer instance points to a material that will be instantiated at runtime.

In order to optimise rendering process, if a material is shared among many object, only one material is created, this will reduce draw calls.

Now for your solution, you need to duplicate your material and assign the new one to the new object. Now, when you change it on one side, it does not affect the other since they are using different material. On the other hand, you increased the draw call.

Upvotes: 2

Related Questions