Comment puis-je mettre à l’échelle l’objet de jeu dans le moteur Unity en fonction de différentes tailles d’écran, en dehors du canevas (objets non UI – objet de jeu réel) ?

la programmation


 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.

Ce que j’ai essayé :

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.

Solution 2

Solution 3

Utilisez un objet de jeu d’interface utilisateur vide et laissez le canevas faire le calcul, définissez la position de l’objet de jeu souhaité (non UI) sur cet objet de jeu vide d’interface utilisateur via un script 🙂

コメント

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