I'm making an interactive book for windows users and i'm using 4.6 UI system. I tested my application on lots of computers using various windows versions. It works fine with windows xp, windows 7, windows 8 and 8.1. But some of the windows 8 and 8.1 computers are producing a weird bug.
Here is how it should look like
and here it is in windows 8
Btw i have lots of images in my application. I'm putting them in my project with .bytes extension and creating sprite on runtime. My code to do this is :
void TextAssetToSprite(int pNo)
{
TextAsset tmp = textAssetArray[pNo] as TextAsset;
Texture2D imgTexture = new Texture2D(1, 1);
imgTexture.LoadImage(tmp.bytes);
Rect rectangle = new Rect(0, 0, imgTexture.width, imgTexture.height);
Vector2 pivot = new Vector2(0.5f, 0.5f);
Sprite firstSprite = Sprite.Create(imgTexture, rectangle, pivot);
imageControl.sprite = firstSprite;
tmp = null;
imgTexture = null;
Resources.UnloadUnusedAssets();
}
I don't know what i'm doing wrong. I've done hours of research but found nothing similar. When i create sprite in the editor and use it on UI image component it works as expected but it's not an option because there are lots of png images in my application and it's size will be too much. Please suggest me a way to fix this. Any help will be greatly appreciated.
It's been a long time since I posted this. I don't know if unity fixed the issue or not. Problem was when I was creating the Texture2D I was just giving it width and height parameters but some operating systems change the default settings for Texture2D. So here is the solution. Change
Texture2D imgTexture = new Texture2D(1, 1);
to
Texture2D imgTexture = new Texture2D(2, 2, TextureFormat.RGB24, false);