Simple scripts featuring uploading picture to your server and generate QR codes from the pictures' url. There is a Test_WebTool sample scene showing how I use the scripts.
This project use LitJson to parse Json files and ZXing to generate QR codes.
WebTool.cs
UploadPhoto(Texture2D _textureToUpload, string _fileName)
uploads _textureToUpload
as a png with _fileName
as its filename. Internally this function uses UnityWebRequest to upload the picture to urlForUploading
with bodyKey
and mimeType
.
If the uploading is successful, it parses downloaded json string to get the picture's url for QRCodeGenerator.cs to generate a QR code. Note that it's for my use case and it may not fit your need ;-)
OnUploadPhotoReqFinish(bool success, string photoUrl)
is called when the WebRequest finishes.
QRCodeGenerator.cs
GenerateQRCode(string _textToEncode)
encodes _textToEncode
to a Texture2D.
OnQRCodeGenerated(Texture2D _texture)
is called when the QR code is generated.
This project use Git submodule gm_WebcamTool. You need to call
git clone --recurse-submodules <URL>
when you clone this reposiory.