- Home /
UI resizable in-game window
I want to make some kind of window in my game such as windows in OS Windows or Linux. So I made them draggable but I can't figure how to make them resizable in proper way. I have 2 corners (Bottom-Left and Bottom-Right) that I can drag to resize window, but I need to make the right one resize my window only in one side (in that case in right). But using localScale I can only scale the whole window in right and left sides together. It's hard to explain the thing I want to implement, but as an example just try resizing window in your OS, that's the thing I need.
Answer by Bunny83 · Jun 13, 2021 at 12:25 PM
Well, that's all just a question of where is your pivot / origin of your window? Most UI systems reference everything from the top left corner of the parent space and not the center. That means resizing the bottom right corner does not "move" the window at all since the position of the window is determined by the top right point. However resizing for example at the left edge we also have to change the position of the window as we are dragging it. This is all just elementary school math ^^. So it's hard to tell from your description how you have set up your "windows", what you actually used to implement them, where your origin of the window is and so on.
In almost all cases changing the size is quite different from changing the scale. Yes, some elements may need to be scaled in order to change their size, however you should be aware of that scaling an object actually stretches the object.
The UI system has many ways to achieve the same things in different ways. There are ways to position things relative to anchor points and have things adjust their size relatively but also provide the size in pixels. So this all highly depends on the setup of your objects.
Your answer
Follow this Question
Related Questions
Input Field caret position is wrong when I type Chineese using Win10 System IME. 1 Answer
Unable to follow UI transition HOW-TO in Unity 5 0 Answers
How to make a UI Canvas not appear again after the first time the user hits the "I Agree" button. 2 Answers
How to display new panel replacing the first one 1 Answer
Unity5 UI Different Screen Resolution and 2D Line problem 0 Answers