in the mobile game we are designing there exists three somehow similar menus:
Main Menu (with a bunch of icons like home, settings, share,toggle
sound,....)
Pause Menu (almost the same with just the text and icon sizes and
placement changes)
EndGame (very similar to pause menu with options to restart game)
now, there are at least two ways I can think of creating these menus:
Create one menu and change positions and sizes of needed icons/texts
in script
Just create 3 different panels in unity UI and call each one that is
needed.
As the assets used in both cases will be the same (well, in second case maybe more game objects) which one is a better solution?
I can write the script as easily as I can create menus (both take almost the same amount of time to develope)
I would recommend to make some kind of MenuViewManager class, with ability to load menu view from XML file. This can lead you to nice translation system in the future and can be very responsive for changes.
Here I've found some article, which can help you start:
http://unitynoobs.blogspot.com/2011/02/xml-loading-data-from-xml-file.html
I recommend having one Canvas with multiple panels. Each panel can be for a different menu (main, pause, game over) or a different set of options in the same menu (main, settings).
Have a script on the Canvas with places to drag each panel. Then turn on/off the panels from code.
You can also create a script to attach to the panels, which has public Button variables, which you can assign in the inspector. The Button objects you drag there in the inspector can be prefabs, so you can reuse them in any menu.
The more reuse you have, the more efficient it will be.
Related
In Netlogo how can I make a second page to the interface, or a pop-up HUD (Heads up Display), to store widgets that I don't use frequently and simply clutter up the main interface?
Rationale: multiple widgets ( sliders, switches, etc.) are helpful for SETUP but then I'd like to hide them to keep the interface clearer, smaller, and less overwhelming to viewers.
Volker Grimm suggested that a set of tabs, each opening a pop-up window to manage different portions of complex models would be helpful.
Since the pop-up might have its own viewing area, you could use it to visually adjust parameters, such as a Normal or Poisson distribution that you want to use for input, without having to use your main interface's viewing area to accomplish this.
In fact, being able to open a second ( or Nth ) graphics window ( "world") into your model could be helpful
Preferably the pop-up would have persistent memory and could be hidden or shown with a single click.
Here's my own solution to the pop-up HUD question.
I used the LevelSpace extension ("ls") in the main model to pop up a second model containing the widgets I'm trying to show or hide as desired.
The main model has more details about how this works in the INFO tab.
In this prototype proof-of-concept, the main model simply displays a few turtles wandering around the world and has hide/show buttons to pull up the HUD.
The HUD has 3 sliders that can be used to set the number of turtles, size of turtles, and shape of turtles, and a button to upload those new settings all at once to the main model. The main model will check once every GO step for updates and apply them and mark them applied.
Alternatively, the HUD can be set to be in automatic-update mode, so the sliders are basically live and as you move each one the changes immediately show up in the main main model ( at the next GO step ).
It works! The full models with the interface buttons and INFO tabs are in the Netlogo Modeling Commons as "Popup-HUD part 1 of 2" and "Popup-HUD part 2 of 2" for download. ( just search for "HUD" as there are only two hits. )
They won't run over the web because they use the LevelSpace extension which isn't available there. You need to download the main model to be able to read the INFO tab.
These are free to copy, modify, etc. so long as attribution is made ( CC 4.0 )
A big problem for me creating diagrams in visio (and powerpoint and similar programs) is that if you have a background object, it blocks you from selecting multiple objects by lassoing. Instead you end up moving the background around, this is annoying.
In many applications there's an option to "lock" or "protect" a specific object so it becomes un-selectable while still visible on the drawing. In Visio there is no simple way of doing this as far as I'm aware.
There's a rather convoluted way of doing this, it feels to me like Visio designers wanted to make this difficult on purpose. The methods I'm aware of I list here, feel free to let me know of a better way(s)
You can protect objects from selection by going to (hidden by default) Developer tab and pick "shape design"-> protection -> selection. However this does not actually protect them from selection, which makes sense . To actually protect the said object from selection, you have to open drawing explorer, which is also hidden by default and the visibility tickbox is in hidden by default Developer tab under show/hide section.
Drawing explorer, however won't highlight whatever object you have selected in the drawing, another unexplicable design decision. If you want to see the name of the object you've selected with live update, you have to enable the diagram navigation pane. That's found in View tab on Show section under "task panes" icon. This pane does highlight whatever you've selected and you can rename the object to give it a meaningful name, but not change the shape in any other way.
To finally protect that shape from selection, right click on the top level document on the drawing explorer and pick "Protect document" and tick "shapes" and hey presto, now your background rectangle is visible but not selectable. Very straightforward indeed
There are also layers which offer similar functionality but they naturally come with their own gotchas.
You can see layers on the Drawing explorer under foreground pages, page name, "Layers" tree. To move an object on a specific layer, you cannot do it by right clicking on the object, because of course you can't. There's an assign to layer button in Home->Editing->Layers->"Assign to Layer", which will let you select the layer(s) for the selected object. You can also do this by right clicking on an object from the Drawing explorer, but you have to know the object name, because there's no reverse selection .. The object name you can get from the Diagram navigation. By default "protected" and "lock" layers do nothing.
To change what the layers do, you again go to the Home -> Editing -> Layers and select "Layer properties". This is also available from Drawing explorer by right clicking on the "layers" tree under a specific page. Here you can control if the layer is visible and/or protected. However, if you lock a layer, you also cannot move objects to/from it, as that'd be too easy. So you have to untick "lock" if you want to move stuff in and out of a protection layer.
So there are two awkward ways of doing that that I'm aware of.
If the shape really is a background object then maybe you should be looking at putting the shape on a background page. You can then make it the background page for your active page. That'll fix all your shape selection problems.
I want to make a backpack UI that can dynamically add and delete items like a menu, but every item in it is a picture (not a text)
I found many tutorials but all of them are panels with slots that need I to set their positions previously. I wonder if there is a better way to make it more easily.
I think the best way is to use a Vertical Layout Group:
https://docs.unity3d.com/Packages/com.unity.ugui#1.0/manual/script-VerticalLayoutGroup.html
Obviously for adding and deleting in player, you have to create buttons with relative scripts.
I don't get how you sort UI elements Z-index in Unity inside a Canvas, is it by hierarchy order ?
I'm trying to do a settings screen like in this video: https://www.youtube.com/watch?v=-qNo1jloR_k
It's quite simple, you click on the button and it set the whole panel as first sibling in the hierarchy.
But this is what I get:
https://gyazo.com/cec14f21df2ded191875e6a8cfd9f124
Also, my gameplay panel had a red background, my graphics panel a green one, and my sound panel a yellow one.
I could avoid this problem by changing alpha on panels, but would like to make it work with z sorting... that I can't seem to understand on Unity.
Using unity 2017.1.2 and .NET 4.6 .
The child that is lower in the hierarchy is rendered on top of other ones.
Let's say there are 2 panels. panel1(red) and panel2(green).If the hierarchy is like this:
-panel1
-panel2
Then panel2 will be rendered on top of panel1. So, you'll see green panel.
Hope this answers your question.
Another suggestion, it is better to deactivate the unused panels and activate only the used panels. Because, if the unused panel is active, when it's not shown, it'll still take the processing power which is a waste. For example, if you have animation in the main menu, but currently you are showing the settings panel, your approach will keep the animations running in the main menu.
The JavaFX 2 colour picker has a button that pops up a colour chooser pane like so:
I'd like to do something similar, in that I'd like a custom pane to pop up when the button is clicked on and disappear when something else is clicked (in my case, a few image thumbnails). What would be the best way of achieving this? Should I use a ContextMenu and add a pane to a MenuItem somehow, or is there something else I should look at?
It's kind of difficult to do well with the current JavaFX 2.2 API.
Here are some options.
Use a MenuButton with a graphic set in it's MenuItem
This is the approach taken in Button with popup showed below's executable sample code.
Use a PopupControl
Take a look at how the ColorPicker does this in it's code.
ColorPicker extends PopupControl. You could do this, but not all of the API required to build your own PopupControl is currently public. So, for JavaFX 2.2, you would have to rely on internal com.sun classes which are deprecated and will be replaced by public javafx.scene.control classes in JDK8.
Use a ContextMenu
So, I think your idea to "use a ContextMenu and add a pane to a MenuItem" is probably the best approach for now. You should be able to do this by using a CustomMenuItem or setting a graphic on a normal MenuItem. The ContextMenu has nice relative positioning logic. A ContextMenu can also be triggered by a MenuButton.
Use a Custom Dialog
To do this, display a transparent stage at a location relative to the node.
There is some sample code to get you started which I have temporarily linked here.
The sample code does relative positioning to the sides of the main window, but you could update it to perform positioning relative to the sides of a given node (like the ContextMenu's show method).
Use a Glass Pane
To do this, create a StackPane as your root of your main window. Place your main content pane as the first node in the StackPane and then create a Group as the second node in the stackpane, so that it will layer over the top of the main content. Normally, the top group contains nothing, but when you want to show your popup, place it in the top group and translate it to a location relative to the appropriate node in your main content.
You could look at how the anchor nodes in this demo are used to see how this might be adaptable to your context.
Is there a relevant update for this for JavaFX8?
There is not much difference of relevance for Java 8, in general the options are as outlined in this post based on Java 2.2 functionality. Java 8 does add Dialog and Alert functionality, but those are more targeted at use of dialogs with borders, titles and buttons rather than the kind of functionality desired in the question. Perhaps you might be able to start from the Dialog class and heavily customize it to get something close to what is needed, but you are probably better off starting from a blank stage or PopupControl instead.