Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definition: new UI components for ECS 7 #304

Closed
Tracked by #326 ...
menduz opened this issue May 11, 2022 · 2 comments
Closed
Tracked by #326 ...

Definition: new UI components for ECS 7 #304

menduz opened this issue May 11, 2022 · 2 comments
Assignees
Labels
sdk7-blocker Blocks the GA release of SDK7

Comments

@menduz
Copy link
Member

menduz commented May 11, 2022

This issue may be outdated. Check the living spec at https://rfc.decentraland.org/adr/ADR-124


The new UI layouting system of the SDK for the Decentraland Protocol will be based out of FlexBox. That is a bold change that will break compatibility with previous versions of the UI for better portability and standardization.

Flexbox is the next-gen layouting system used in web applications, it is an open and mature standard that is not only used by web browsers but also by native applications and even operative systems. i.e. ReactNative and Unity's UI Toolkit use flexbox for its layouts.

A big win for this decision is that moving away from the legacy Unity-based layouts will enable easier portability of the renderer to other technologies thanks to yoga layout, an open-source library that implements everything needed.

Unlike the legacy UI components, the new UI will be implemented using entities with a special UiTransform component.

The renderer systems must ignore in the 3D camera every entity containing a UiTransform component. Also, all the descendant entities of those with a UiTransform must be filtered out from the 3D camera.

For simplicity and speed, there will be a special perpetual UiRootEntity used as parent for all the UiTransform entities, this entity is the analogous of the RootEntity for the 3D entities. * this may be subject to changes.

The UiRootEntity will act as "canvas" and will accept a UiTransform component to configure some properties. Since it is the root node, the following properties will be ignored: "basis", "grow", "shrink", "align_self", "margin", "position_type" and "position".

The new UI system will also be separated in two types of components:

  • Layout components, to position things in the canvas:
    • UiTransform
  • Rendering components
    • UiBackground to define a background color or image
    • UiLabel to render text
    • UiInput to create text inputs
    • UiButton to create buttons

Rendering components may encapsulate logic for the renderer like styles for different states like Active or Hover, delegating the position and size of the component to the UiTransform

Another big advantage of this new model is that eventually, a playground (like yoga's) can be created to rapidly prototype new UIs and it is nowadays a common technology among web developers, reducing drastically the entry barrier.

Another interesting use case is a visual debugger/inspector. In early stages of development, to test that all features work as expected, a web debugger should be created to render side-by-side code and the generated layout using the CRDT protocol.

The proposed UiTransform is added to the ECS in this PR decentraland/js-sdk-toolchain#150

@menduz menduz added the sdk7-blocker Blocks the GA release of SDK7 label May 11, 2022
@menduz menduz added this to the ECS 7.0.0 milestone May 11, 2022
@menduz menduz self-assigned this Jun 2, 2022
@menduz menduz mentioned this issue Jun 2, 2022
5 tasks
@D4rWiNSS
Copy link

D4rWiNSS commented Aug 9, 2022

We should have also UiImage for images

@menduz
Copy link
Member Author

menduz commented Aug 9, 2022

We should have also UiImage for images

What would be the practical difference between UiBackground and UiImage?

@menduz menduz changed the title Definition of new UI components for ECS 7 Definition: new UI components for ECS 7 Aug 15, 2022
@menduz menduz closed this as completed Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk7-blocker Blocks the GA release of SDK7
Projects
Status: Done
Development

No branches or pull requests

2 participants