Search Unity

Confused about material instances

Discussion in 'Editor & General Support' started by eXonius, May 3, 2016.

  1. eXonius

    eXonius

    Joined:
    Feb 2, 2016
    Posts:
    207
    If I have a lot of objects which I want to have the same material and color I have understood I should use renderer.sharedMaterial, and that I do.

    However, sometimes I have seen it says "materialname (clone)" in the editor and sometimes I've seen something like "materialname (clone) (instance)".

    Which one is correct? Which one should my objects have to have as few draw calls as possible?
     
    kana1939 likes this.
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,291
    Have you read the docs?

    material
    Modifying material will change the material for this object only.
    If the material is used by any other renderers, this will clone the shared material and start using it from now on.


    sharedMaterial
    Modifying sharedMaterial will change the appearance of all objects using this material, and change material settings that are stored in the project too.

    So if you ever access the material property then you will get the (Instance) appear next to the name, if you want the changes to apply to all objects then only use sharedMaterial.

    If you want to make changes to some of the objects but keep the same material then look at MaterialPropertyBlock as an alternative.
     
  3. eXonius

    eXonius

    Joined:
    Feb 2, 2016
    Posts:
    207
    Thanks, so as I understood it if I see it says "(instanced)" I've done something wrong, i.e. not used sharedMaterial but material.
     
  4. kana1939

    kana1939

    Joined:
    Jan 4, 2022
    Posts:
    13
    "Do materials named 'Material(Clone)' and 'Material(Instance)' have internal differences, or is it simply due to differences in how they are created (using 'material_set' and 'Material.Instantiate')?"