Skip to content

Commit

Permalink
通信ロジックブラッシュアップ
Browse files Browse the repository at this point in the history
ダウンロード進捗取得、ダウンロード進行中フラグを立てる
  • Loading branch information
BiwaCoder committed Jul 5, 2017
1 parent 869e5da commit 08109cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
1 change: 1 addition & 0 deletions Assets/Scripts/Logic/HttpLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public IEnumerator StartDownLoad(){
downLoadProgress = www.progress;
yield return www;
}
isDownStart = false;

if (!string.IsNullOrEmpty (www.error)) {
downLoadProgress = -1;
Expand Down
33 changes: 14 additions & 19 deletions Assets/Scripts/Logic/HttpLogicWebRequestLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class HttpLogicWebRequestLogic : SingletonMonoBehaviour<HttpLogicWebReque
string url;
float downLoadProgress;
bool isDownStart;
UnityWebRequest www;

public void SetUrl(string targetUrl){
isDownStart = false;
Expand All @@ -14,31 +15,25 @@ public void SetUrl(string targetUrl){

public IEnumerator StartDownLoad(){
isDownStart = true;
var request = UnityWebRequest.Get (this.url);
yield return request.Send();
Debug.Log(request.responseCode.ToString() + ":" + request.downloadHandler.text);

/*using(WWW www = new WWW(url)){
while (!www.isDone) {
downLoadProgress = www.progress;
yield return www;
using (www = UnityWebRequest.Get (this.url)) {
yield return www.Send ();
isDownStart = false;
if(www.isError) {
Debug.Log(www.error);
}
if (!string.IsNullOrEmpty (www.error)) {
downLoadProgress = -1;
Debug.Log (www.error);
}
else {
downLoadProgress = 1;
Debug.Log (www.text);
Debug.Log (www.responseCode.ToString () + ":" + www.downloadHandler.text);
}
}*/
}
}

public float currentProggress(){
return downLoadProgress;
if (www == null) {
return -1;
} else {
return www.downloadProgress;
}

}

public bool isNowDownLoading(){
Expand Down

0 comments on commit 08109cd

Please sign in to comment.