- Home /
Making objects be at size and place for every phone size
I want to ask if making all your object UI elements is a bad practise. Im currently animating a object but because its UI it lags and jitters, but if its in the scene it works great. I've got used to making all object UI, because that way I can set the anchors and it look good and every phone size because everything is sized propery. So my question is, how to make all my objects be in the scene(not UI) and be at the same position and size no matter the screen size, just like if they were UI elements.
Answer by akisrn · May 19, 2016 at 02:18 PM
This tutorial pretty much covers everything. Check it out.
As I said in the question, I don't have problem with the UI, its the objects that are in the scene and that they are at different places for every phone.
Answer by coolraiman · May 19, 2016 at 02:16 PM
there is a lot of way to do that
some people just make a root parent and scale it to the screen ratio of the phone. by example your screen is made in a 16:9 ratio but the phone screen is 4:3, you divide by the denominator so you go from 16:9 to 5.3:3 and then scale everything in % based on that
then if all child use relative position, everything should work fine
this may look dirty on some phone. but in general its not that bad
Do all people who develop for mobile do that ? Isn't there a easier option ?
Definitely not all. I've never done that. Completely depends what kind of a result you want.
There's hundreds of questions about "how to make a game look the same on all phones" on Unity Answers and the simple answer is "you can't". If 2 devices have different aspect ratios, all you can do is compromise in different ways.
Then again for example Unity's camera implementation already automatically scales everything no matter what the resolution. An orthographic camera with size 5 always shows exactly 10 world units from top to bottom. If you want your game to always show the same amount of the world height wise, then your game would "look the same on all phones" without any additional coding.
To me the idea of using ui anchors for game logic feels weird because it could easily lead into situations where the game plays different on different screens. If you anchor something to the bottom corners of the screen, then they will be farther apart on wider screens.
The gameplay and how you present it to the player are two different things. You shouldn't compromise the former because of the latter :)
sorry to tell you ivayloDev that scaling the root parent is the most lazy and simple fix
its not bad in general but as nosekills said, there is no perfect way to do it
Your answer
Follow this Question
Related Questions
Scaling game to fit screen size 2 Answers
Unity 5 UI Fill Any Screen 2 Answers
Draw texture the same size of a sprite 1 Answer
Input.mousePosition.x is greater than Screen.width ... huh? Anyone know why? 1 Answer
ShowAchievementsUI screen rotation 2 Answers