Hello
I have a class that has a static variable of type Material. I am trying to initialise/set the value for that static variable but it doesn’t seem to be working, ie, the Material never has the correct material(it just looks like a pink rectangle).
How do I set the value of a Material programmatically(not using the inpector)?
I have the following Materials inside the folder “MyProject/Assets/Materials/” called BrickBreakable, BrickSolid, BrickItem.
class BrickItem : MonoBehaviour {
public static Material breakableMaterial = new Material("BrickBreakable"); // always looks pink when it shoudld be a brick colour
public static Material solidMaterial = new Material("BrickSolid");
public static Material itemMaterial = new Material("BrickItem");
void Start() {
if (state == State.BRICK_BREAKABLE)
material = breakableMaterial;
}