- Home /
The question is answered, right answer was accepted
Issue with texture loading
Basic script:
public class Loading : MonoBehaviour {
public GameObject plane;
string [] str = { "http://users.metropolia.fi/~lucasc/texture_1a_by_jakezdaniel-d1b6lmo.jpg",
"http://users.metropolia.fi/~lucasc/texture_34_by_sirius_sdz-d1ihrrm.jpg",
"http://users.metropolia.fi/~lucasc/a1ca03e0ca1cda6ae5ea0e873318a306349c0934.jpg",
"http://users.metropolia.fi/~lucasc/a34290b07559b4e3881f816fe97a3d02f4f2232b.jpg"
};
int index = 0;
void Update(){
if(Input.GetKeyDown(KeyCode.Space)) {
StartCoroutine (StartRoutine());
}
}
IEnumerator StartRoutine () {
WWW wwwTexture = new WWW(str[index]);
yield return wwwTexture;
if(++index == str.Length) { index = 0; }
MeshRenderer meshRenderer = plane.GetComponent<MeshRenderer>();
meshRenderer.material.mainTexture = wwwTexture.texture;
}
}
Using this with a basic cube on scene (nothing else, just drag the cube into the plane slot), then the first two textures loads fine but the third and fourth just keeps coming up with problem. The actual texture gets offset to 0.3 and the remaining 0.6 is filled with either some other textures or some distorsion. Funny it does not happen on all textures.
I guess it might have to do with the nature of those. I filled a bug report but maybe someone has a solution as we would need a quick solution or explanation.
Expected:
What I get:
See the extra purple thingy that should not be there? This problem came up with Unity5 and was working fine on Unity4.
As a test, what if you load the 4 textures as Resources ins$$anonymous$$d of web, leaving everything else the same. Do you get the same behavior then? If not that would indicate a problem with WWW, otherwise maybe something changed with how the Plane is dealing with materials?
print the www.error also try to put the texture obtained in a GuiLayout.Label to check if it is co$$anonymous$$g correctly.
So if i assign the texture manually to a material, no issue. If i use File.ReadAllBytes and create the texture, same issue.
I tried assigning it to plane, quad, cube and a custom plane and all fails. Quad goes even crazier duplicating the texture within the texture.
The unity dev $$anonymous$$m is meant to be working on right now but i guess i am kot their only bug, so it may take time for a fix.
I realise this is actually a duplicate for this http://answers.unity3d.com/questions/257080/www-loading-texture-problem-when-built.html i found another older similar issue esrlier from the forum but i cant get it back. It had no solution either.
It seems the issue would come from the main texture assignment line as if assign manually, works, if done by code,breaks.
I also tried with SetTexture in case but nope, still there. And www.error is null.
I guess it has to do with the nature of the texture which is some kind of mask.
Answer by fafase · Jun 24, 2015 at 01:08 PM
It seems to have been fixed in yesterday's patch (23/06/2015):