如何根据画布外部的不同屏幕尺寸(非 UI 对象 – 实际游戏对象)缩放 Unity 引擎中的游戏对象?

编程


 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

解决方案3

使用一个空的 UI 游戏对象并让画布进行数学计算,通过脚本将所需的游戏对象(非 UI)位置设置为此 UI 空游戏对象:)

コメント

タイトルとURLをコピーしました