decentraland / creator-hub

MIT License
0 stars 4 forks source link

Include ScaleFactor in UiCanvasInformation #215

Open nearnshaw opened 3 days ago

nearnshaw commented 3 days ago

This is to make it easier for content creators to adjust the size of their UIs, even if the player has a retina display.

We can replicate what Pejo did here, but running on the engine or the SDK. We can then expose the scaleFactor number as part of the UiCanvasInformation component

In a comment in that property in the protocol we could put that it’s based on a 1920x1080 ratio.

For the creator then, if I want to add a rectangle with text in it, I would do:

<UiEntity uiTransform={{ 
        width: 700 * UiCanvasInformation.get(engine.RootEntity).ScaleFactor, height: 'auto' }}>
        <Label
            value="This is a label"
            color={Color4.Red()}
            fontSize={29 * UiCanvasInformation.get(engine.RootEntity).ScaleFactor }
            font="serif"
            textAlign="top-left"
        />
    </UiEntity>