- Home /
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.Rotate(0,0,0);
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;
Answer by Owen-Reynolds · Jul 20, 2014 at 03:02 PM
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.
Thanks. Sorted that after posting the issue. Anyways thanks for the explanation.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
[Any plugin] One PSD For all Huds in Game ? 1 Answer
Importing from Bleder texture problems. 4 Answers
Unity3d load sprite from Textures folder 0 Answers