Created
May 25, 2017 12:08
-
-
Save aki017/5e37db37153594bbceca4186b6f00b50 to your computer and use it in GitHub Desktop.
screenshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var camWidth = Screen.width; | |
var camHeight = Screen.height; | |
var rt = new RenderTexture(camWidth, camHeight, 24); | |
Camera.main.targetTexture = rt; | |
var snapShot = new Texture2D(camWidth, camHeight, TextureFormat.RGB24, false); | |
Camera.main.Render(); | |
RenderTexture.active = rt; | |
snapShot.ReadPixels(new Rect(0, 0, camWidth, camHeight), 0, 0); | |
Camera.main.targetTexture = null; | |
RenderTexture.active = null; | |
Object.Destroy(rt); | |
var bytes = snapShot.EncodeToPNG(); | |
var form = new List<IMultipartFormSection> {new MultipartFormDataSection("image", bytes)}; | |
var www = UnityWebRequest.Post("https://api.imgur.com/3/image", form); | |
www.SetRequestHeader("authorization", "Client-ID c1e604cb4c2b81f"); | |
yield return www.Send(); | |
Debug.Log(www.downloadHandler.text); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment