[ad_1]
I want to consider the edges/borders of the screens and place the gameObject accordingly with sufficient padding across those edges/borders of screens. Also I have to keep the scale(x & y) equal. I have to prevent it from being bigger or smaller and getting out of the view or overlapping with other objects in the game scene. BTW it's a 2D game.
我尝试过的:
I have tried Camera.main.ScreenToWorldPoint but don't know how to guide it to get what I want. And I don't think it would be sufficient to do that.
解决方案2
我将你的问题放入 Google 搜索中: 如何根据画布外的屏幕尺寸自动缩放统一引擎中的游戏对象?[^]
它给了我这个 YouTube 视频: 如何缩放 UI 以适应游戏中的任何屏幕分辨率 – 迷你 Unity 教程 – YouTube[^]
解决方案3
使用一个空的 UI 游戏对象并让画布进行数学计算,通过脚本将所需的游戏对象(非 UI)位置设置为此 UI 空游戏对象:)
[ad_2]
コメント