WebCamTexture to circular sprite
Hi, I'm creating an application for iOS and android and need to capture a picture to be used as a projectile. The user is displayed a video feed (working) and when they press the video feed a picture will be taken and cut into a circle shape by first converting the picture into a texture2d. When I test it on my phone the video feed works correctly but when I capture the picture and try to make it a circle I receive an output of a gray square.
     void finalizeSpritePicture(){
         if (camTexture != null) {
             IntPtr pointer = camTexture.GetNativeTexturePtr ();
             Texture2D camTexture2D = new Texture2D (256, 256, TextureFormat.ARGB32, false, true);
             camTexture2D.UpdateExternalTexture (pointer);
             camTexture2D = CalculateTexture (camTexture2D);
             profileSprite = Sprite.Create (camTexture2D, new Rect (0, 0, 256, 256), new Vector2 (128, 128));
             profileImage.sprite = profileSprite;
             camTexture.Stop ();
         } else {
             Debug.Log ("Failed to capture picture: No Camera Feed");
         }
     }
 
 
     Texture2D CalculateTexture(Texture2D sourceTexture){
         Color[] c = sourceTexture.GetPixels (0, 0, sourceTexture.width, sourceTexture.height);
         Texture2D b = new Texture2D (256, 256);
         for (int i = 0; i < (256 * 256); i++) {
             int y = Mathf.FloorToInt (((float)i) / ((float)256));
             int x = Mathf.FloorToInt (((float)i - ((float)(y * 256))));
             if (256 * 256 >= (x - 128) * (x - 128) + (y - 128) * (y - 128)) {
                 b.SetPixel (x, y, c [i]);
             } else {
                 b.SetPixel (x, y, Color.clear);
             }
         }
         b.Apply ();
         return b;
 
     }
 
               Please provide help as to why the webcam picture cannot be cut into a circle and turned into a sprite. Thank you!
Your answer
 
             Follow this Question
Related Questions
When I run getPixel32 () in WebcamTexture, only black pixels are returned. 1 Answer
Change Texture2D readable flag at runtime (or at least a workaround to do that) 0 Answers
RenderTexture to Texture2D very slowly 0 Answers
Memory Leaks when play pictures from local card using Sprite.Create 1 Answer
2D Sprite.Create isn't working 0 Answers