- Home /
Unsupported texture format
Unity version: 2018.2.6
After loading Texture2D with DownloadHandlerTexture using UnityWebRequest, When I try to change the format of Texture2D I cannot change the format due to a title error. How do you know the solution?
Below is the relevant source code.
using (UnityWebRequest webRequest = UnityWebRequest.Get(url)) {
DownloadHandlerTexture texDl = new DownloadHandlerTexture(true);
webRequest.downloadHandler = texDl;
yield return webRequest.SendWebRequest();
if (webRequest.isNetworkError) {
Debug.LogError("www url:" + url + " Error:" + webRequest.error);
OpenTimeOutView(type, url);
yield break;
}
if (!mLoadSpriteList.ContainsKey(key)) {
Debug.Log("StartDownloadResource key:" + key);
Texture2D texture = new Texture2D(texDl.texture.width, texDl.texture.height, TextureFormat.DXT5Crunched, false);
texture.SetPixels(texDl.texture.GetPixels());
texture.Compress(true);
texture.Apply();
mLoadTextureList.Add(key, texture);
Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
mLoadSpriteList.Add(key, sprite);
}
}
Japanese: Unityのバージョン:2018.2.6
UnityWebRequest を使って DownloadHandlerTexture で Texture2Dを読み込んだ後に、 Texture2Dのフォーマットを変更しようとすると タイトルのエラーが発生してフォーマットを変更できません。 解決方法ご存じの方はいらっしゃいますでしょうか?
下記、該当のソースコードになります。
,Unity version: 2018.2.6
After loading Texture2D with DownloadHandlerTexture using UnityWebRequest, When I try to change the format of Texture2D I cannot change the format due to a title error. How do you know the solution?
Below is the relevant source code.
using (UnityWebRequest webRequest = UnityWebRequest.Get(url)) {
DownloadHandlerTexture texDl = new DownloadHandlerTexture(true);
webRequest.downloadHandler = texDl;
yield return webRequest.SendWebRequest();
if (webRequest.isNetworkError) {
Debug.LogError("www url:" + url + " Error:" + webRequest.error);
OpenTimeOutView(type, url);
yield break;
}
if (!mLoadSpriteList.ContainsKey(key)) {
Debug.Log("StartDownloadResource key:" + key);
Texture2D texture = new Texture2D(texDl.texture.width, texDl.texture.height, TextureFormat.DXT5Crunched, false);
texture.SetPixels(texDl.texture.GetPixels());
texture.Compress(true);
texture.Apply();
mLoadTextureList.Add(key, texture);
Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
mLoadSpriteList.Add(key, sprite);
}
}
Japanese: Unityのバージョン:2018.2.6
UnityWebRequest を使って DownloadHandlerTexture で Texture2Dを読み込んだ後に、 Texture2Dのフォーマットを変更しようとすると タイトルのエラーが発生してフォーマットを変更できません。 解決方法ご存じの方はいらっしゃいますでしょうか?
下記、該当のソースコードになります。
Your answer
