WebGL Screenshot & share like the benchmark

Hi…

Im trying to re-create the screenshot & functionality of the screenshot and the facebook share like the WebGL benchmark with no success… @jonas-echterhoff_1 could you share the code, or give me some guidelines please?

thank you very much

Hey,

I found getting this set up with facebook to be more work then I had expected. Quite possibly, this has become easier now, that facebook has released an SDK for Unity WebGL:

When I did that, this was not available, so I had to use the JavaScript SDK.

But, anyways, some pointers:

  • I would get a screen shot using Texture2D.ReadPixels and Texture2D.EncodeToPNG
  • I would send those png bytes to a JavaScript function, which would then upload this image to facebook using an XMLHttpRequest
  • then I would use the JS Facebook SDK to post a story, referencing this uploaded image.
  • the story type/format would previously need to be configured in your facebook app developer setup page

I found it easier to simply upload the picture to the facebook photos on your account, then to use a custom story type like this. The problem is that if you do that, Facebook requires the text caption you use to only contain text input manually by the user - ie, you are not allowed to pre-fill that with information like the benchmark score or browser used.

@jonas-echterhoff_1 Thank you very much! This was really helpfull… i think ill give the WebGL SDK a try.