I'm not familiar with Unity's new UI system of 4.6 and later. I would like to display a series of buttons on screen and have them center-aligned and breaks into the next line when screen width is reached. The old OnGUI function no longer seem working so I wonder how can I achieve this?
You need to use UI's layout system. Usually, you just create a Layout Group and populate it with objects that have Layout Element component.
Related
My UI elements inside my panels are scaling fine with screen size, but the distance between my different panels is not. I have 3 panels in my scene at different relative position which i set at 1920x1080 reference resolution, and switching between them using animation. But when i change the game view resolution, these panels do not align themselves right. Here are the screenshots:
These are the panels at 1920x1080 which i set.
These are the panels when i set game view resolution to 2340x1080. As you can see, the "settings" panel is still fine but the "more settings" panel does not repositioned correctly.
The same thing happens when i set game resolution to 800x480.
Please help me..
The easiest way you can achieve what you are attempting to do is to use a component called GridLayoutGroup. Add this component to a parent object, child all three of your UI elements to it, and set the column count to 2. I can add an example in a bit, currently building a project.
Edit: Here is a gif example of the above solution.
I am migrating game from windows phone to flutter card game. I cannot find the way how to keep the card on the top after dragging.
Stack order is too complex and problematic for such simple action and would involve 4 player active, not active cards, cards on the table, combination sets re-arrangement :( In Windows phone there was a Rectangle with ZIndex which i could set to any rectangle on the screen.
I am missing something similar in flutter. I cannot believe that stack order is only way to solve this because it would make any game development impossible.
I am not using any game engine (maybe thats a problem) but i feel like i do not need it because it is not game-loop based game it is event based - click, drag etc.
Do you know any solution how i can achieve that?
There are 2 options -
1. Stack
Update the position of its children by mutating the List and calling setState or use Positioned.
2. Material
The Material widget has a property named elevation. Set it's value dynamically to achieve the effect
I heve some problems with making UI in Unity3d.
I have a dropdown element with 5 DDN items. This is original structure of DDN.
But on wide screen DDN items not responsive(2736x1824).
This is on FreeAcpect screen.
I want to make an elements responsive, but unity don't make it itself.
I try to set BestFit checkbox of Text element but no results.
I have created a Dropdown with default properties and it is showing responsive behavior for bigger resolutions as well, as expected.
What you might be missing is the UI Scale Mode in Canvas Scaler component.
Also see
Designing UI for Multiple Resolutions.
I am working on a game using GTK3 as a rendering technique (terrible idea, but it's a school project).
My gameobjects are made of Image widgets and are placed in a Fixed container. It's working pretty well, however when i move widgets beoynd right or bottom border, the window automatically grows along with it.
I want the window to stay at the sam size, event if widget leaves its area and becomes invisible. It works when i move widget past the upper or left border.
I tried using gtk_widget_set_vexpand and gtk_widget_set_hexpand. My window is set as not resizable (gtk_window_set_resizable).
Is there any way I can achieve this?
This isn't the right way to use GTK+. GTK+ is intended for laying out widgets in a GUI program.
There are better options for animating 2D elements. One that works with GTK+ natively is the Clutter library. You can also integrate SDL or OpenGL or something like that if you so choose.
That being said, you can also use GtkLayout instead of GtkFixed, or put the GtkFixed in a GtkScrolledWindow and hide the scrollbars and set the scroll policy to prevent scrolling. It's still technically misuse, and in fact GtkFixed (and possibly GtkLayout too but the docs don't say) is really not supposed to be used anymore unless absolutely necessary because it doesn't give you automatic support for tricky UI layout problems, but it doesn't have extra dependencies.
I have created a level editor using new UI system in Unity3D.
Using Level Editor:
I can drag the ui elements,
I am able to save them in scriptable objects
But how could i save and load them at runtime?
I mean, if i create a level with some {width x hight} resolution and if i load it on different resolution, then the whole UI positioning get distorted.
How could i anchor them correctly programmatically?
Any help would be appreciated.
There are good video tutorials about the 4.6.x UI here:
http://unity3d.com/learn/tutorials/modules/beginner/ui.
Especially for positioning the elements I recommend watching: http://unity3d.com/learn/tutorials/modules/beginner/ui/rect-transform.
I suggest you learn how to use the anchor correctly first. If you want to change the position and size of UI element in a script you can do that through the RectTransform component. It offers functions like offsetMax,offsetMin and sizeDelta for position your UI element. The functions you need to use depend on your anchor setting.
as LokiSinclair said. You just need to Adjust the Scale that the new UI provided. It is the four Arrow on the Canvas of each Object and every UI object is inheriting their scale behavior from their Parent.