UnityGUI

I just read through the UnityGUI Reference manual, and experimented a bit with it in my game, and was wondering how exactly I would make sure that a button stays in an area and keeps relatively sized across multiple screen sizes. I can use Screen.width/2 and such for the position, but the “anchor” is in the Upper-left corner so I’d need to subtract half of the width and height of the Gui Object. O_o Just a bit confused. Love the idea though, so much more than GuiTexts and GuiObjects with hacks and scripts all over them. :stuck_out_tongue:

Check out the Layout stuff, but also, you could simply make the size a percentage of the screen size.

your button width could be Screen.width * 0.25 for instance. Right? Text size I’m not sure yet.

Gotta say that the design GUI system pretty much rocks. It’s SO easy to throw up a quick set of buttons if you need them and so far they seem flexible enough to use for just about anything.

One thing I noticed, though… double clicking on a word in a text box does NOT select the word. :-/ I’ll have to add that to the wish list along with other GUI stuff if someone doesn’t beat me to it.

I figured something out. Now another thing though, is there any way to center text?

I read through the docs yesterday but since I’m in the “waiting for free upgrade camp”, I haven’t experimented yet.

However, as far as I can tell, there is no built in support for fadein/out for example. Anyone have a feeling for whether that would be quick to implement given the new system? From the few examples I looked at it didn’t seem built to “track” the objects once they’re created, or am I missing something?

When making a new GUIStyle, how do I get it to keep the original UnityGUI design? All I want to do is center the text in a textfield, but when I make a GUIStyle that does, the original graphic for the textfield goes away leaving plain text.

Have you created a local instance of the GUI Skin in your project? Once you have, you can modify either the stock styles or create custom ones.

Ah, its true. :smile: Thanks DOC.

I’ve been reading the scripting reference, and two things spring to mind:

  1. The new GUI system is really handy. No work at all to create rather complex systems.

  2. I still can’t seem to understand if/how it’s possible to reference the various created elements (buttons for example). GUI.Button for example will create a new button, and will return true if clicked. GUI. GUI.VerticalSlider will return the slider value. And so on.
    So since there’s no instantiate call (it’s all being handled automagically), I don’t quite understand how to store references to the object in order to be able to manually reposition them for example.

Am I being ignorant, or is this the way it’s supposed to work? If so, that’s fine, I’ll just have to choose when to use the built in system (which is simple to use and powerful) or use my own stuff which is a bit more flexible.

TIA! :slight_smile:

Just caught the fact that OnGUI is called every frame as long as the script is active. Does that mean that I can vary the parameters for the various gizmos each frame and achieve animation…?

dfvdan
Yes.

Brilliant, no?

Not sure on the shading thing. Now everyone’s making me want to play with this and I can’t right now. :smile: