-
I'm having a situation where I have a map inside a menu and I want to do 2D transform processing on various sprites and place them on the map, but I'd like to keep the convenience of the ui components around the map. After trying the naive approach of assuming I can just place sprites with transforms as children of a ui element and expecting that they'd behave somewhat like ui elements with the absolute positioning (ie, mostly ignored by the layout strategy), I got this warning and definitely not what I was expecting in terms of placement on the map: "Unstyled child in a UI entity hierarchy. You are using an entity without UI components as a child of an entity with UI components, results may be unexpected." So as I've come to understand it, there is a paradigm shift there and while style elements do transforms under the hood (if I understand correctly what the doc said), these are not compatible with custom user managed tranforms on non-ui components. I assume that leaves me with the option of doing some placement arithmetic where I play with z indices a little and place the map with no ui components on top of the ui menu with no parent/child relationship between them (that or I reimplement the behavior of all ui components using non-ui components, but to my sensibilities that feels a bit like reinventing the wheel, especially as someone who is familiar with web development). But before I do that, I feel like I should ask: Is there any kind of component strategy in bevy for a ui element to behave like a ui element on the outside, relative to its parent and siblings, and as a lower level element on the inside where you can have more fine grained control over the tranforms of its children (kind like an html5 canvas I guess)? Apologies if my question seem a bit naive to bevy aficionados, I'm learning quite a bit, but many parts of the engine are still very unfamiliar to me. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Actually, I see in this example that the transform was updated with the presence of a style component for an ui element to achieve rotation: https://bevyengine.org/examples/ui-user-interface/overflow-debug/ The documentation for nodebundle indicated that the transform component was automatically managed by bevy based on style, but maybe it isn't a hard rule and it is ok to overwrite it. I'll have to experiment with that. The other component I added to spritebundle was a tiled imagescalemode component to achieve repetition of some images along an axis, but I think I may be able to use that component with an imagebundle as well which has a style component too. So it feels not quite right, from a design perspective (it feels like ui elements should be those higher level primitives for menus), but perhaps (I will have to experiment) I can actually render all the processed art of the map using ui components and circumvent the ui/non-ui hierarchy incompatibility problem I had that way, this time (although it feels like I'll eventually hit a wall with this). |
Beta Was this translation helpful? Give feedback.
-
If anybody else with a similar issue stumbles upon this post, the zindex strategy didn't work, but this did the trick: #14816 (comment) |
Beta Was this translation helpful? Give feedback.
If anybody else with a similar issue stumbles upon this post, the zindex strategy didn't work, but this did the trick: #14816 (comment)