mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 12:08:46 +00:00
处理UnityWebRequest版本兼容问题
This commit is contained in:
@@ -107,7 +107,7 @@ namespace XCharts
|
|||||||
var url = "https://raw.githubusercontent.com/monitor1394/unity-ugui-XCharts/master/Assets/XCharts/version.json";
|
var url = "https://raw.githubusercontent.com/monitor1394/unity-ugui-XCharts/master/Assets/XCharts/version.json";
|
||||||
var web = UnityWebRequest.Get(url);
|
var web = UnityWebRequest.Get(url);
|
||||||
yield return web;
|
yield return web;
|
||||||
if (web.isNetworkError)
|
if (IsNetworkError(web))
|
||||||
{
|
{
|
||||||
isNetworkError = true;
|
isNetworkError = true;
|
||||||
networkError = web.error;
|
networkError = web.error;
|
||||||
@@ -144,7 +144,7 @@ namespace XCharts
|
|||||||
var url = "https://raw.githubusercontent.com/monitor1394/unity-ugui-XCharts/master/Assets/XCharts/CHANGELOG.md";
|
var url = "https://raw.githubusercontent.com/monitor1394/unity-ugui-XCharts/master/Assets/XCharts/CHANGELOG.md";
|
||||||
var web = new UnityWebRequest(url);
|
var web = new UnityWebRequest(url);
|
||||||
yield return web;
|
yield return web;
|
||||||
if (!web.isNetworkError)
|
if (IsNetworkError(web))
|
||||||
{
|
{
|
||||||
Debug.LogError(web.error);
|
Debug.LogError(web.error);
|
||||||
}
|
}
|
||||||
@@ -192,5 +192,29 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
changeLog = sb.ToString();
|
changeLog = sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_5 || UNITY_2017_1
|
||||||
|
public bool IsNetworkError(UnityWebRequest request)
|
||||||
|
{
|
||||||
|
return request.isError && !IsHttpError(request);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public bool IsNetworkError(UnityWebRequest request)
|
||||||
|
{
|
||||||
|
return request.isNetworkError;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_5
|
||||||
|
public bool IsHttpError(UnityWebRequest request)
|
||||||
|
{
|
||||||
|
return request.responseCode >= 400;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
public bool IsHttpError(UnityWebRequest request)
|
||||||
|
{
|
||||||
|
return request.isHttpError;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user