Answer the question
In order to leave comments, you need to log in
How to find out the length of the Canvas in units through a script in Unity?
As far as I know, these squares in the Scene window are called units. To optimize the game for different devices, I need to get the actual value of the Canvas length in units through the script, is this possible?
Answer the question
In order to leave comments, you need to log in
Well, somewhere at the level of theory - translate screen coordinates into world coordinates. The camera has methods (ScreenPointToWorld). But this will work adequately only for an orthographic camera - as soon as you add depth, you will have to contrive more.
There is a simpler option, which is about canvas for different resolutions. You just need to add a few components that already exist in unity (I don’t remember now, but I can look if you are interested) that themselves adapt the canvas and its contents to different resolutions
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question