I want to find out if a certain material is assigned to an object. The problem I am encountering is that the material I want to check for equality with is assigned by an exposed variable in the inspector ( not instanced), and my other material is instanced.
In this code, materialNeeded is assigned in the inspector, and obj is the object
var materialNeeded : Material; //Assigned through inspector
This code never returns true. This is because the objects that I send in have had their materials assigned during runtime ( which they should ), and that makes Unity clone a runtime instance for them.
So how do I find out which the prototype material was?
What you are looking for is the renderer.sharedMaterial variable, which contains the non- instanced version of the Material. Hope it helps! Peace!
answered Apr 21 '10 at 09:52 AM