IEnumerator ShowLoadDialogCoroutine() { // Show a load file dialog and wait for a response from user // Load file/folder: file, Initial path: default (Documents), Title: "Load File", submit button text: "Load" yield return(FileBrowser.WaitForLoadDialog(false, null, "Load File", "Load")); // Dialog is closed // Print whether a file is chosen (FileBrowser.Success) // and the path to the selected file (FileBrowser.Result) (null, if FileBrowser.Success is false) Debug.Log(FileBrowser.Success + " " + FileBrowser.Result); if (FileBrowser.Success) { ModalDialog.Instance.Show("Processing File", "Please wait while your file is encoded into a txn and broadcast"); try { BitIndexUtils.QueryUtxos(Authenticator.Instance.Identity.Address, utxos => { var utxo = utxos.First(); Debug.Log(JsonConvert.SerializeObject(utxo)); UtxoUtils.BuildTxnFromUtxo( Authenticator.Instance.Identity.PrivateKey, utxo.ToUTXO(), OpReturns.MakeBlob(Encoding.UTF8.GetBytes(FileBrowser.Result))) .Spend(txn => { var value = $"https://bico.media/{txn}"; Debug.Log(value); ModalDialog.Instance.Hide(); ModalDialog.Instance.Show("File successfully uploaded", $"Check it out at: {value}", "View Online", "Ok"); ModalDialog.Instance.CallbackYes.RemoveAllListeners(); ModalDialog.Instance.CallbackYes.AddListener(() => { Application.OpenURL(value); }); InputField.text = value; }); }); } catch (Exception e) { ModalDialog.Instance.Hide(); ModalDialog.Instance.Show($"Something went wrong, try again later", $"{e.GetType()}: {e.Message}", "Ok"); } } else { ModalDialog.Instance.Show("File Browser Error", "Could not pinpoint file to upload", "Ok"); } }
void Start() { var pix = Texture2D.GetPixels32(); var tex = new Texture2D(Texture2D.width, Texture2D.height); tex.SetPixels32(pix); tex.Apply(); // TODO: Refactor this after getting some sleep var width = 0; var height = 0; const int maxSize = 1024; if (tex.width > tex.height) { if (tex.width > maxSize) { width = maxSize; height = (tex.height * maxSize) / tex.width; } } else { if (tex.height > maxSize) { height = maxSize; width = (tex.width * maxSize) / tex.height; } } TextureScale.Point(tex, width, height); Debug.Log($"Texture is {tex.width}x{tex.height}"); var buffer = tex.EncodeToJPG(); Debug.Log(buffer.Length); BitIndexUtils.QueryUtxos(Identity.Address, utxos => { var utxo = utxos.First(); Debug.Log(JsonConvert.SerializeObject(utxo)); UtxoUtils.BuildTxnFromUtxo( Identity.PrivateKey, utxo.ToUTXO(), OpReturns.MakeImg(buffer)) .Spend(txn => { Debug.Log($"https://bico.media/{txn}"); }); }); }