Instantiating material due to calling renderer.material during edit mode.

Im trying to create a custom plugin for creating quads and assigning texture to them. I get “Instantiating material due to calling renderer.material during edit mode”. Any help on this would be greatly appreciated.

GameObject Game_Quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
Game_Quad.transform.localScale=new Vector2 (Quad_Width,Quad_Height);
Game_Quad.transform.position=new Vector3(0,0,2f);
Texture2D Tex =  (Texture2D) Resources.Load("Assets/Textures/C_1_A", typeof(Texture2D));
Game_Quad.renderer.material.mainTexture = Tex;

Try using sharedMaterial?

If you don’t understand the problem yet, it’s because dot-material is actually a hefty acessor function that works like a standard string smart-pointer. material starts out as a pointer to a shared material Asset. As soon as you change (or even look at it!) Unity split off a temp personal copy for you. This is for things like 6 cubes sharing a material, and one changes itself to red.