Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by galealuke · Oct 29, 2014 at 06:40 PM · cameraresolutionscreen

Handling different resolutions?

Hi guys, so I just made a simple top-down shooter to get used to unity. I found the co ordinates where the camera ends, and spawned monsters from there, and had a life bar on the top left..etc

Now when I play it on android suddenly I see a whole mess because the view is not the same from pc resolution to the phone resolution (duh).

So is there a way that I can reference directly the camera co-ordinates and instantiate according to where the edges of the camera are? I assume this is how one would handle different screen resolutions...

Thanks, Luke

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tanoshimi · Oct 29, 2014 at 07:03 PM 0
Share

Welcome to the world of Android development: one platform, millions of different device configurations :)

Generally speaking, it's not resolution that presents the problem: a game running on a 320x240 screen and one running on a 640x480 screen should show the same extents - Unity does that for you automatically. But the problem is when aspect ratio changes: what do you show on a screen that is, say, 640x600? What to do with the 120 pixels or extra "height"?

There's no universal way to handle different screen sizes: scaling, letterboxing, zoo$$anonymous$$g are all options. In your question, you want to know the worldspace coordinates of the four corners of the visible camera viewport - is that right?

avatar image galealuke · Oct 29, 2014 at 11:02 PM 0
Share

Yes pretty much. I guess now it zooms in when it finds a different aspect ratio, which is not desirable as some stuff is left out of the screen. Apparently it seems harder than I thought so I'm gonna have to do some research about this..thanks :)

avatar image galealuke · Oct 30, 2014 at 07:05 PM 0
Share

So now the weirdest thing is happening to me. I used width and height to and then converted it using ScreenToWorldPoint. For some reason when I instantiate moving objects it works fine, but still objects do not show on the screen, even though they are instantiated in the object hierarchy. Then if I log the position generated by ScreenToWorldPoint, and instantiate them on that position they show. Has this ever happened before?

Thanks

avatar image MrSoad · Oct 30, 2014 at 08:48 PM 0
Share

Are you doing anything with scale anywhere, if anything that relates to the placing procedure is not at a scale of (1,1,1) you can get odd behavior...?

avatar image galealuke · Oct 31, 2014 at 09:56 AM 0
Share

well I change the scale in a lot of the objects, I didn't know that's bad..although now I changed the object I'm trying to instantiate to 1,1,1 and it's still not showing.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by CasvanMarcel · Dec 19, 2014 at 11:54 PM

I posted a response here to solve this horrible problem http://gamedev.stackexchange.com/questions/79546/how-do-you-handle-aspect-ratio-differences-with-unity-2d/89973#89973

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by MrSoad · Oct 29, 2014 at 07:03 PM

You can do something like this :

 private var fScreen_Width : float;
 private var fScreen_Height : float;
 
 fScreen_Width = Screen.width;
 fScreen_Height = Screen.height;

which will give you your current screen dimensions. You can then use this info to adjust whatever you need to.

Edit: You can than do what tanoshimi says and calculate the ratio from these values and use that as your base for adjustments.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image galealuke · Oct 29, 2014 at 11:04 PM 0
Share

Thanks, I'll try to figure out how to work with these :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Scaling Orthographic Camera Up 2 Answers

2D Game. Screen, Camera and coordinates. 0 Answers

4:3 aspect ratio 0 Answers

Orthographic cameras and screen resolutions 1 Answer

Make camera have a fixed screen size 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges