How do I duplicate a material?


What I need to do is take the material of an object, and duplicate the material. How would this be done? Thank you!

@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’.

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.