【解決方法】Unity エンジンでキャンバスの外側 (非 UI オブジェクト – 実際のゲームオブジェクト) のさまざまな画面サイズに応じてゲームオブジェクトをスケーリングするにはどうすればよいですか?

プログラミングQA


 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をコピーしました