Click here to Skip to main content
16,018,938 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
 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.


What I have tried:

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.
Posted
Updated 7-May-23 22:27pm
v2
Comments
Dr. Punch 5-Sep-23 12:36pm    
Did you found a solution for your problem?
I have the same problem, I need to adjust my prefabs(gameObjects) to scale with the resolution of the device the game has been used on. Otherwise the mechanics of the gameplay change.
I know that big game studios are using assets with different dimensions for different resolutions.
But as a solo game dev that's a lot of work and very time consuming.

 
Share this answer
 
Comments
arpitsrivstva 8-May-23 4:09am    
NO! The video is for canvas/UI elements like all the other youtube videos. But I need anything to scale and set the padding boundaries of my element according to different screen sizes outside the canvas - Not UI objects.
Graeme_Grant 8-May-23 4:40am    
The unity help room would be a better place to ask this question. Here is the link: All Posts in Help Room - Unity Answers[^] or their Forums: Unity Forums[^]

Both of these official links were in the Google Search link that I provided above. There are many more options / solutions, you just need to look.
Use an empty UI gameobject and let the canvas do the math, set the desired gameobject (non UI) position to this UI empty gameobject via script :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900