panel size to window size (Unity) - c#

So I tried building my game, but I saw that the objects that were set on a panel didnt keep their position. If I click on max window size then the objects move away from their original position. How can I solve this? (see images for extra info)

You should set ui elements' anchor position
For example my Restart button is in top-left place. When screen size change, it doesn't change position. To do this, click your ui object, click anhcor-presets section, press alt key and select a position which you want.
Also, Canvas scale may help you for resizing ui objects,when you change screen size

Related

UI objects on same position for every resolution

There is a problem i created a button and text which is display correct on android resolution but when i change the resolution to free aspect it change the position of button and text like this
I tick the button component Image (Script) preserve aspect and changing the anchors of both object like this
but nothing happen i want to display these two on same position where it is when changing any resolution.
First of all, do not use Free Aspect to test different resolutions. Free aspect isn't really a resolution and often you can see bugs that you will not ever see on real devices.
For your problem anyway you have what's called Anchors in each UI element. An anchor defines where you want to "attach" your UI element and especially to what element or corner of the screen you want to attach it. For your example, on the Rect Transform, click on the square drawing (representing the anchors) and choose Bottom Left.
Your element will be moved, you can move it where you want to and it will always be attached to the bottom left corner of your screen:
If you want to know more about UI for multiple resolutions, you can go here: http://docs.unity3d.com/Manual/HOWTO-UIMultiResolution.html
Good luck!

How to touch toggle hidden under png image sprite in Unity3d

I have a scrollable set of toggles partially hidden under png image. The image serves as a "border" for the toggles. The problem is that if the image is in hierarchy on top of the toggle (what I want for composition reasons) the toggles stop to work. Is there a way to make image ignore touches and not prevent touches of toggles under it? I know that I can cut image into borders and get rid of the transparent hole but maybe there is simpler way?
Thank you
I typically solve this problem by adding a Canvas Group component to the transparent element.
Canvas Group Documentation - http://docs.unity3d.com/Manual/class-CanvasGroup.html
It has a property that allows you to set a UI Element to a "Non-Interactable" state, which will allow you to click / touch through it with your event system.

how to fix button position when resolution is changed in unity after built

When I add a button and play the game in Unity editor, it remains in its required position. But when I build and run it, the button's position gets misplaced. I want 1366 x 768 screen resolution with all buttons well positioned.
I suggest you to use Canvas Scaler (to control the scale of your game on several devices) and Anchors (to keep the elements in the position where you want to) on your buttons.
http://docs.unity3d.com/es/current/Manual/script-CanvasScaler.html http://docs.unity3d.com/Manual/UIBasicLayout.html
In the scenario where your buttons are normal size in the editor and exporting to your phone makes them smaller, make sure your Canvas has the Canvas Scaler component, and set the UI Scale Mode to "Scale With Screen Size".

Bigger mouse cursor in Silverlight

I have a silverlight application in which I have to click on some pictures, if I hover over them for 3 seconds approx.
The problem is that if the pictures are a bit small in size, and the mouse moves a little, it moves out of the respective picture clicking area and selects another picture.
I have tried using a custom image in place of the default mouse cursor, but can this mouse be enlarged in some way so that it has a larger clicking area under it and not only the tip of the mouse pointer?
I think you're thinking about this the wrong way around. The mouse pointer simply defines a coordinate on the screen, rather than an area. If you want mouseover/click etc to be more generous, and give a wider area of interaction, you should make the target area larger.
So in the case of some small image, you can surround it with a larger area to handle the mouseover or click events, for example by surrounding it by a transparent border (note that elements with a transparent background will receive mouse events, unlike elements with no background).

How can I develop scale like measure it add on in Firefox

I want measuring tool in project that will be same as measure it in Firefox (add-on). How to do this?
To get such a think to work you'll need an application that runs as a tray icon or something like that. Then you open your application and tell him, that you'd like to measure.
Now, you'll go and put a transparent window onto the whole screen(s) and wait for a mouse move event. Within the mouse move event, you'll check the mouse button state. If it is going to be hit you know the starting position and you can draw some kind of user-control at this position and if the user releases the mouse button, you're going to stop the resizing of your user-control.
The user-control itself should be semi-transparent and checking for the resizing and/or paint events, to draw the ruler lines around the border.
Last but not least you can show some kind of tooltip or labelcontrol in relation to the position and size of your user-control and screen bounds to give some status informations.
To get a good starting point about how to get the transparent overlay part done, you can take a look into ObjectListView Overlay.
--EDIT--
One solution could be:
Create a separate transparent windows form
Upon certain key press, for instance Ctrl+Shift+R, show your app with lower transparency level; so that user can see the background.
Draw ruler upon form load
You may allow user to move the ruler window with mouse click.

Categories