decentraland / sdk

PM repository for SDK
Apache License 2.0
4 stars 4 forks source link

Introduce `UiCanvasInformation` component #531

Closed menduz closed 1 year ago

menduz commented 1 year ago

UiCanvasInformation serves a purpose of providing information to the secene for custom layouting based on devicePixelRatio, device orientation and canvas sizes are in exclusive charge of the implementation of the SDK libraries themselves. Removing any layouting responsibility from the renderer for the sake of keeping the semantics simple and backwards compatible. This will create an inversion of control in which the scene will decide everything in relation to the scene UI.

UiCanvasInformation component

This component is added to the RootEntity of the scene by the renderer. It is REQUIRED that every renderer sends this component to the scene if the UI features are enabled.

message UiCanvasInformation {
  // informs the scene about the resolution used for the UI rendering
  float device_pixel_ratio = 1;
  // informs about the width of the canvas
  int32 width = 2;
  // informs about the height of the canvas
  int32 height = 3;
  // informs the sdk about the interactable area. some implementations may change this area depending on the HUD that is being shown. this value may change at any time by the Renderer to create reactive UIs
  Rect interactable_area = 4;
}

More information at https://github.com/decentraland/adr/pull/157

gonpombo8 commented 1 year ago

related https://github.com/decentraland/sdk/issues/629