Quantcast
Channel: Questions in topic: "css"
Viewing all articles
Browse latest Browse all 78

In WebGL, is it possible to make UI Coordinate scale with CSS style?

$
0
0
Hello,
I am using Unity 2021.1.28, built to WebGL.

What I was trying to do, is to (A) force the render resolution of my WebGL build to be 1280x720, while (B) scaling it to be displayed fullscreen in the browser window. In the html file, I tried to use canvas DOM attributes width/height to do (A) and css style width/height to do (B) ![alt text][1]
And this is the result: https://youtu.be/zRtoAdZ7mtQ

I wrote a script that prints Screen.width and Screen.height with onGUI(). As you can see in the video, the resolution is fixed at 1280x720, and it is forced to be fullscreen in the browser, which is what I want. (It's stretched and looks blurry, but this is ok in my use case) However, it seems that the UI coordinate is fixed at 1280x720 as well. And it isn't scaling with the browser window. Thus I can't click on the UI correctly and the mouse hover effect doesn't look right.
Neither UGUI nor UI Toolkit works.

I was wondering is it possible to make UI Coordinate scale with CSS style? It would be so great if anyone could shed some light! [1]: /storage/temp/193423-screenshot-2022-03-04-173146.png

Viewing all articles
Browse latest Browse all 78

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>