Search Unity

Can we send an image to browser via Application.ExternalCall ?

Discussion in 'Formats & External Tools' started by WikiMalik, Jun 12, 2015.

  1. WikiMalik

    WikiMalik

    Joined:
    Nov 13, 2014
    Posts:
    16
    I am bouncing variables back & forth from unity web player to browser, in order to collect facebook user info without using facebook SDK (not very easy to use). I manage to pass rest of the stuff in, but I'm stuck on the screen capture.


    var snap = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
    snap.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
    snap.Apply();
    var screenshot = snap.EncodeToPNG();
    Application.ExternalCall ("PostScore", screenshot)

    Can this be done? Cause my current code is not working.
     
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Well kind of... After you encode to png, base64 encode it. Then send the base64 string. You can actually display an image in the browser using the base64 string