Like the topic says. I’m trying to learn basics of GUITextures. I know there are addons like ezGUI and NGUI and Unity GUI, but I’m trying to learn basics of Unity, and would like to use GUITextures instead of newer GUI.
I’d like to create a simplistic menu and inventory for learning purposes. So far I’ve been able to create most of the things but run into problems with transformations under parent. I tried to google and custom search but didn’t find anything useful so far.
Problems:
Parented GUITextures “line up” on Y axis, and translating them in Y doesn’t work even in game mode.
localPosition doesn’t seem to be working either
Pixel inset seems to be working
Questions:
Is it possible or even a good idea to parent GUITexture to another GUITexture? Like inventory slots parented to inventory background, or menu buttons parented under menu background.
Is pixel inset only option to move GUITextures under parent ?
Is it OK to translate root parent GUITexture, as it seems most logical way of translation, respecting screen aspect ratio which pixelInset isn’t doing
Here is a picture, but I think text explains it better. Left picture, using pixel inset naturally works, but using position, GUITexture boxes stack on top of each other in Y axis. Haven’t had time to test it today, maybe there is some setting which I don’t know about yet or I should just use pixel inset.
EDIT: Big brown box is GUITexture, in both cases smaller grey boxes are parented under big box GUITexture.
Well, now that I had time to test this a bit more…
Seems like Unity has a strange way of handling GUITexture transforms.
When creating new GUITexture by selecting image, then selecting menu item GameObject/Create New/GuiTexture, Unity defaults scaling to [0,0,1].
This for some odd reason seems to be Unity screen friendly setting, changing it to [1,1,1] which one might expect to be “correct setting” stretches bitmaps to unexpected size. However, if with this transform I parent something else under this GUITexture it’s position will naturally act like it’s parent transform is [0,0,1] moving it to parents origin.
For some reason yesterday I probably had something set bit differently resulting in bit different Y axis behavior, maybe I scaled the parent in x.
Solution: Parent inventory slots and bg under normal GameObject with [1,1,1] scale. Just wondering if there would be another way to do this without extra objects.
EDIT: This renders OnMouseDown and so on unusable, so I guess I’ll have to use pixel inset.
I learned little bit of UnityGUI already, but then came across threads on performance issues with Unity GUI, so I decided to give guitextures a try.
BTW. I already got the pixel inset stuff worked out for my inventory test, and I think I can get around normal GameObject being parent if I want to drag the inventory. But I think this might eventually be time well wasted except for learning thing or two about how things work in Unity.