Comments (9)
It seems to me that there's a size factor (2:1 in that case) I'm not applying (or UIToolkit is not applying), and it affects to pixel positioning. Am I right?
from uitoolkit.
First of all you should use the positioning methods (pixelsFromXxxYyy and positionFromXxxYyy) AFTER endUpdates and matchSizeToContentSize are called. When switching to HD all pixel positioning methods multiply the values with 2, so the positions stay relatively the same.
from uitoolkit.
After doing so, I'm still having the same problem. I'm doing:
var layout2 = new UIVerticalLayout(spacingBetweenItems);
layout2.beginUpdates();
layout2.verticalAlignMode = UIAbsoluteLayout.UIContainerVerticalAlignMode.Top;
layout2.addChild(but4, but5, but6);
layout2.endUpdates();
layout2.matchSizeToContentSize();
layout2.pixelsFromTopLeft((int)(layout1.height + Mathf.Abs(layout1.position.y)) + spacingBetweenItems, spacingBetweenItems);
from uitoolkit.
Can you position the layouts without adding anything from layout1? I mean do they display correctly if you try to do, pixelsFromTopLeft, pixelsFromBottomLeft, pixelsFromTopRight and pixelsFromBottomRight?
from uitoolkit.
Yes, they do. As I said, And if I hardcode 118 instead of Mathf.Abs(layout1.position.y), things work great!, so:
var spacingBetweenItems = 9;
...
var layout2 = new UIVerticalLayout(spacingBetweenItems);
layout2.beginUpdates();
layout2.verticalAlignMode = UIAbsoluteLayout.UIContainerVerticalAlignMode.Top;
layout2.addChild(but4, but5, but6);
layout2.endUpdates();
layout2.matchSizeToContentSize();
layout2.pixelsFromTopLeft(109 + spacingBetweenItems, spacingBetweenItems); // 118, hardcoded instead of using his layout above
Works great in both SD & HD. However, I don't want to hardcode this, but get a relative to it's above layout distance.
from uitoolkit.
What does layout1.height report just before you begin your work on layout2? I don't think you should use the position.y value. Since the height will change whether it's in SD or HD mode, you probably need to do something like:
int factor = UI.instance.isHD ? 2 : 1;
layout2.pixelsFromTopLeft(layout1.height / factor + spacingBetweenItems, spacingBetweenItems);
from uitoolkit.
That's what I thought, that there's a factor needed to be applied if using UIObject's properties. So if you don't encourage using position.y, how can I get my desired behavior? (stacked horizontal layouts, just like horizontal layouts nested inside a vertical layout would work... something like a table, let's say)
from uitoolkit.
Thinking about you can use position.y, but you need to account for the HD factoring.
int factor = UI.instance.isHD ? 2 : 1;
layout2.pixelsFromTopLeft((int) ((Mathf.Abs(layout1.position.y) + layout1.height) / factor) + spacingBetweenItems, spacingBetweenItems);
from uitoolkit.
Great, let me give it a try.
from uitoolkit.
Related Issues (20)
- UIBox
- Middle image tiling in UIVerticalPanel HOT 1
- Scrollable text
- Memory Leak? HOT 1
- swipe detector not working
- Add UIText to UIScrollableVerticalLayout HOT 1
- Changing Highlighted image is awkward HOT 1
- UISprite's setSpriteImage doesn't work
- Fixed reappearance of #71
- One touch, multiple buttons
- UIJoystick background image does not appear on the iPad
- Multiple Atlases - Zindex / Layer HOT 4
- LICENSE? HOT 13
- Cannot recognize multiple text font resolutions 1x ,2x and 4x.
- Text Positioning and Button positioning are not the same. HOT 1
- Set button text HOT 1
- UIToolkit fails after build the project
- adding UIText to UIGridLayout
- Licensing HOT 1
- UIText not always showing up
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uitoolkit.