Hi guys,
I’m currently working on my first Unity project, but not my first game, and I’m figuring out how to do 2D interface. So far I find it quite easy even thought its kinda different from others engine I’ve used.
In other project, we used Texture Atlas to optimize performance, using less video memory, etc. I want to do the same here but I found out there is no quick and simple UseTexture(Texture myTex,Rect uvs).
Of course I was able to get this to work by doing this :
mSliderBack = new Texture2D(192, 40, TextureFormat.ARGB32, false);
mSliderBack.SetPixels(mAtlas.GetPixels(0, 216, 192, 40));
mSliderBack.Apply();
mSliderStyle.normal.background = mSliderBack;
It’s working but how efficient is it and it’s clearly data duplication. I could probably release mAtlas after getting all my “subTexture” from the atlas but I wonder how unity handles the Texture2D. Does it pad the data to keep texture in power of 2 ? Is it the best way to do so ?
Plus doing so give me a lot of Texture2D object where I wanted only to handle 1 and use coordinates.
So is there an alternative or am I doing like its supposed to be ?
I also notices the PackTextures function but no function to actually use the packed texture or something. Unity is the third engine I use to build a professionnal game but the first one to not expose texture UV for 2D stuff. Needless to say the method I used in the code snippet above is not very intuitive to build interfaces.
Am I missing something ?
Thanks in advance !