كيف يمكنني قياس كائن اللعبة في محرك الوحدة وفقًا لأحجام الشاشة المختلفة، خارج اللوحة القماشية (كائنات غير واجهة المستخدم – كائن اللعبة الفعلي)؟


 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

استخدم كائن لعبة فارغًا لواجهة المستخدم ودع اللوحة القماشية تقوم بالحسابات، واضبط موضع كائن اللعبة المطلوب (غير واجهة المستخدم) على كائن اللعبة الفارغ لواجهة المستخدم عبر البرنامج النصي 🙂

コメント

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