private void Start() { if (!renderer) { renderer = GetComponent <Renderer>(); } oldTexture = renderer.material.mainTexture as Texture2D; texture2D = new Texture2D(oldTexture.height, oldTexture.width, GraphicsFormat.R8G8B8A8_SRGB, TextureCreationFlags.None); if (transparentToTexture) { var transparentColors = new Color32[oldTexture.height * oldTexture.width]; transparentColors.Foreach(x => x = new Color32(0, 0, 0, 0)); texture2D.SetPixels32(transparentColors); } else { texture2D.SetPixels32(oldTexture.GetPixels32()); } texture2D.Apply(); renderer.material.SetTexture(Painter._MainTex, texture2D); }