Search Unity

Can I detect when a material goes from SharedMaterial to an instanciated copy?

Discussion in 'General Graphics' started by AlxHHH, Aug 10, 2021.

  1. AlxHHH

    AlxHHH

    Joined:
    Dec 2, 2012
    Posts:
    1
    Hi,

    I am trying to undesrtand why my instanciated gameobjects end up using induvidual instances of the material, instead of sharing the same shared material.

    I have tried to make sure I do not acces the property ".materal". on the new instanciated gameobjects, as I know that would make local copies/instances of the material. As far as I can tell, I never touch it. I know there is no code I have written that manipulates anything in the ".material". I never read that property, and never asign anything to it.

    Even so, they end up using material instances.

    Is there a way to debug how/when this is happening? Can I listen to an event somewhere?

    Can an parent Animator somehow interfere and make material instances, even though there is no material values being animated?

    The thing is I can instanciate the same prefabs in a simpler way, puting them in the top of the transform herarchy, and when I do that they atually end up sharing same same material, as intended.

    But like I say, when I have the object deeper in the structure, animate them, reparent, translate and so on, each instanciated gameobject end up with its own instance of the material.

    I have spent two evenings on this now, and I am out of new things to try...

    Anyone got any insight or suggestion?

    /Alexander