GUITexture PRVTC 4-Bit, square dimensions: no problems.
(did not test any other PRVTC-combo, because quality is too bad anyways regarding GUI elements …)
GUITexture 16-bit RGB / RGBA, square or non: leaks.
OnGUI (tested an empty OnGUI function): leaks.
Edit: This is a minor leak. You should check your app for yourself with Instruments / Leak and decide what to do.
GUI.xxx: not tested, yet.
Long story short: Use square 24/32-bit images on GUITextures. Use GUIText.
Personally I will continue using OnGUI / GUI.xxx for interface element heavy situations even if it leaks. On the other hand GUI.xxx is a no-go for in-game HUDs, because it’s slower than GUITexture.
Hopefully the 16-bit issues will be fixed soon, because 24-bit isn’t always necessary to show up a nice GUI – saves space, memory and loading time.
I’ve been looking at the GUI material and I’m confused by what you mean by GUI.xxx! I know I should understand it, but - what exactly do you mean? Do you mean items like GUI.Lablel? If OnGUI is ok, then can’t you say:
function OnGUI() {
GUI.Label (Rect(0,(480-512),512,512), "", background);
}
Or is that using a GUI.xxx?
And - just for clarification, as I’m new to this - is there any preferred file type for the graphics to use with Unity-iPhone? Or just any square 24 bit will do?
Lastly - have you looked at 8 bits per channel? I find that you can get acceptable images using 8 bits if you’re careful.
With GUI.xxx I mean functions like GUI.Button or GUI.Label …
They work, but at least the function OnGUI leaks memory. I think it was something like 11kb, so pretty neclectible in most cases …
AFAIK Unity converts images internally, so it doesn’t matter which format as long as the image shows up in Unity. Important: “square image” means a square image with dimensions of a power of two – 64x64, 128x128, 256x256 etc.
I guess you’re talking about indexed 8-bit images – Unity doesn’t support them.
I guess, I’m a n00b all the way around! I’ve been saving my images out of Photoshop CS3, and I’ve been using RGB files. I’m given the choice in Image/Mode/RGB Color of: 8 bits/channel, 16 bits/channel and 32 bits/channel. I simply made the assumption that 8 was smaller than 16 or 32, so I’ve been working in that mode/size. They seem to import into Unity as straight .psd files.
I know this had be asked again and again, and that Unity is hard at work with GDC/Unity2.5 but that would be very helpful for lot of us to know if/when this memory leaks issues will be resolved in the next version of Unity iPhone.
I’m not crazy, I don’t want it to be fixed right now. I just want to know if I must work on another project because the update will not come in the next couple of weeks. Not knowing that is really stressful when you’re near a completed game like ours.
Matieu: I can sympathize. I should have had my app in the store by now, but last minute showstopping problems have held it up. I rely heavily on the OnGui(); and GUI.xxx for all the buttons, as I really like the new GUI interface, but Memory issues seem to be one of the prime suspects (http://forum.unity3d.com/viewtopic.php?t=20485). I’ll try going back and reworking my game to remove the OnGui(); in the HUD, but still skuppered for the time being. If you are planning on anything soon, I’d avoid OnGui(); in the game play screens from everything I’ve now read.
I should have posted a disclaimer – UT is really doing a great job and GUI stuff works great – the leak I detected is a minor one. So before you start changing your project you should check for yourself using Instruments / Leak and decide what to do.
To answer your question: place a GUITexture in your scene, add a script to the GUITexture with something like:
function Update() {
if (Input.GetMouseButtonDown(0) guiTexture.HitTest(Input.mousePosition)) {
// do something
}
}
Are there any statistics that proof this leak and show to which degree it goes?
Because nonsquare texture means that unity has to create a new texture thats square pow 2 and copy your texture in.
The statistics would be interesting for the following reason: does the leak represent the added part or is it actually the original texture that was required to be expanded that leaks?
Also, did you set the texture to be resized to the required format or not in the import settings.