使用astc优化网络图片;workouts链接修改
This commit is contained in:
parent
5480de5c6d
commit
42e23e2f84
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f134d222725933a4a8aa79fee0ebc10c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -111,7 +111,7 @@ public static class App
|
||||
Host = "https://wx.powerfun.com.cn/";
|
||||
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
|
||||
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
|
||||
//Debug.unityLogger.logEnabled = false;
|
||||
Debug.unityLogger.logEnabled = false;
|
||||
#endif
|
||||
var isRower = PlayerPrefs.GetString("IsRowerMode");
|
||||
if (!string.IsNullOrEmpty(isRower))
|
||||
|
||||
@ -66,7 +66,7 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
|
||||
transform.Find("Version").gameObject.SetActive(false);
|
||||
UIManager.ShowAndroidUpdate(info);
|
||||
}
|
||||
|
||||
App.WorkoutsUrl = r.data.Value<JObject>("Apk").Value<string>("Url");
|
||||
#elif UNITY_IOS
|
||||
var sw = r.data.Value<string>("ThirdPartSwitch");
|
||||
transform.Find("Panel/LoginContainer/LoginScrollView/Viewport/Content/FormContainer-Login/Mask/FormContainer/BtnThirdLogin")
|
||||
@ -77,8 +77,9 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
|
||||
Application.OpenURL(info.Value<string>("Url"));
|
||||
Application.Quit();
|
||||
}
|
||||
App.WorkoutsUrl = r.data.Value<JObject>("Ios").Value<string>("Url");
|
||||
#endif
|
||||
App.WorkoutsUrl = info.Value<string>("Url");
|
||||
|
||||
#endif
|
||||
}
|
||||
//if (r.result)
|
||||
|
||||
@ -332,10 +332,10 @@ namespace Assets.Scripts
|
||||
}
|
||||
}
|
||||
UIManager.Instance.StartCoroutine(DownloadImage(img, url,(texture)=> {
|
||||
//if (cache && !propTextureCache.ContainsKey(url))
|
||||
//{
|
||||
// propTextureCache.Add(url, texture);
|
||||
//}
|
||||
if (cache && !propTextureCache.ContainsKey(url))
|
||||
{
|
||||
propTextureCache.Add(url, texture);
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
@ -375,36 +375,53 @@ namespace Assets.Scripts
|
||||
|
||||
static IEnumerator DownloadImage(RawImage img,string MediaUrl, Action<Texture> action = null)
|
||||
{
|
||||
UnityWebRequest request = UnityWebRequestTexture.GetTexture(MediaUrl,true);
|
||||
UnityWebRequest request = UnityWebRequest.Get(MediaUrl);
|
||||
yield return request.SendWebRequest();
|
||||
if (request.isNetworkError || request.isHttpError)
|
||||
Debug.Log(request.error);
|
||||
else if(img!=null)
|
||||
else if (img != null)
|
||||
{
|
||||
var _t = ((DownloadHandlerTexture)request.downloadHandler).texture;
|
||||
_t.name = MediaUrl;
|
||||
img.texture = _t;
|
||||
if (action != null)
|
||||
var data = request.downloadHandler.data;
|
||||
img.texture = Utils.GetDownloadTexture(MediaUrl, data);
|
||||
if (action != null)
|
||||
{
|
||||
action.Invoke(img.texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Texture GetDownloadTexture(string MediaUrl, byte[] data)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
var _t = new Texture2D(4, 4, TextureFormat.DXT5, false);
|
||||
#else
|
||||
#if UNITY_IOS
|
||||
var _t = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false);
|
||||
Debug.Log("使用了壓縮");
|
||||
#elif UNITY_ANDROID
|
||||
var _t = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false);
|
||||
Debug.Log("使用了壓縮");
|
||||
#else //pc
|
||||
var _t = new Texture2D(4, 4, TextureFormat.DXT5,false);
|
||||
#endif
|
||||
#endif
|
||||
_t.LoadImage(data,true);
|
||||
_t.name = MediaUrl;
|
||||
return _t;
|
||||
}
|
||||
static IEnumerator DownloadImageCallBack(RawImage img, string MediaUrl,Action<string> action)
|
||||
{
|
||||
UnityWebRequest request = UnityWebRequestTexture.GetTexture(MediaUrl, true);
|
||||
UnityWebRequest request = UnityWebRequest.Get(MediaUrl);
|
||||
yield return request.SendWebRequest();
|
||||
if (request.isNetworkError || request.isHttpError)
|
||||
Debug.Log(request.error);
|
||||
else
|
||||
{
|
||||
img.texture = ((DownloadHandlerTexture)request.downloadHandler).texture;
|
||||
var data = request.downloadHandler.data;
|
||||
img.texture = Utils.GetDownloadTexture(MediaUrl, data);
|
||||
action.Invoke(MediaUrl);
|
||||
}
|
||||
}
|
||||
/*显示网络图片*/
|
||||
|
||||
/*获取最顶层对象*/
|
||||
public static Transform FindUpParent(Transform zi)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user