- Home /
How do I duplicate a material?
Hello,
What I need to do is take the material of an object, and duplicate the material. How would this be done? Thank you!
Answer by Bunny83 · Jan 21, 2012 at 06:16 PM
I you take a look into the documentation you will see there are 3 different constructors for Material. One takes a string which should hole the shaders source code, one takes a compiled shader object and one that takes an existing Material as parameter (this is the copy constructor).
However in Unity you can clone every object that is derived from UnityEngine.Object with Instantiate. Keep in mind that you can only use the one-parameter-version of Instantiate with objects that doesn't belong to a GameObject.
Answer by Kryptos · Jan 21, 2012 at 07:27 PM
@Bunny83 gave you the code solution. If you want to duplicate the asset in the project view, select it and hit CTRL+D (on Windows) to duplicate it, or right-click 'Duplicate'.
Right ;) As a programmer i always think about code in the first place. However, the question sounds more like the OP was after a scripting solution, maybe i'm wrong.
Anyway, +1
Your answer
Follow this Question
Related Questions
Material/Texture on the Inside of a Sphere 5 Answers
How can I swap an object's texture when I click? 2 Answers
CRT/LCD screen shader (for materials) 4 Answers
Material not shown on imported FBX sphere 0 Answers
change child texture problem 2 Answers