Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Parse;
- public class ParseManager : MonoBehaviour {
- void Start () {
- Download();
- }
- public void Download(){
- string id_facebook = "idfbtest";
- string filename = "hinhanh.png";
- StartCoroutine(LoadFile(id_facebook, filename));
- }
- IEnumerator LoadFile(string id_facebook, string filename) //single method downloads file
- {
- ParseQuery<ParseObject> query = ParseObject.GetQuery("Sync").WhereEqualTo("id_facebook", id_facebook);
- var queryTask = query.FirstAsync();
- while (!queryTask.IsCompleted) yield return null;
- ParseObject obj = queryTask.Result;
- ParseFile pfile = obj.Get<ParseFile>("file_datauser");
- int level = obj.Get<int>("level");
- print ("level " + level);
- Debug.Log(pfile.Url.AbsoluteUri);
- WWW www = new WWW(pfile.Url.AbsoluteUri);
- yield return www;
- //Debug.Log("imageRequest " + imageRequest.text);
- byte[] bytes = www.bytes;
- String urlFile = Application.persistentDataPath + "/" + "ten" + level + ".png";//filename;
- print ("duong dan: " + urlFile);
- System.IO.File.WriteAllBytes(urlFile, bytes);
- }
- }
Add Comment
Please, Sign In to add comment