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
0
Question by benarceneaux · Aug 06, 2013 at 07:58 PM · resolution settings

How do I achieve pixel perfect effect and what do I need to have in mind if I go the Pixel Perfect route?

I know this has been asked before, and please understand that I have read as many Unity Answer questions as I have been able to find. Not to mention numerous tutorials and blogs that discuss Pixel Perfect orthographic cameras. I feel like I'm close but I'm still having issues with getting everything working correctly and there seems to be a few different strategies to achieving this and I think this is confusing me. Honestly, this does not seem all that complicated but something is still confusing me.

Here's what I know:

  1. First I should have a resolution in mind, let's say 1024 x 768

  2. I should also have an idea about the size of my sprites, how about 64 x 64

  3. I create an orthographic camera in the Unity Editor and set the size to 6 because I want to be able to display 12 sprites vertically. (12 units will be equal to the vertical measurement of my camera)

  4. I've set my resolution by clicking Edit > Project Settings > Player and my settings look like this:

      Default Screen Width: 1024
         Default Screen Height: 768
         Supported Resolutions: All of them are checked.
    
    
  5. I create a mesh in blender that is 1 x 1 unit wide according to blender's default scale (I've read that Blender and Unity both use 1 meter as the default unit)

  6. I import the mesh and set the scale to 1 because by default Unity imports .3ds at 0.1

  7. The first texture I create will be the ground(It's a 2D top-down perspective game). I create the texture with the measurements of the resolution because I want this to cover the entire screen.

---Questions--- 1. I know that my 1 x 1 mesh will not work for the background texture because that the mesh will hold only 64 x 64 pixels, what size mesh would I create to hold the background image and how is this calculated?

  1. Are the above steps correct, is my understanding of what I need to do complete or am I missing something? If so can you please point out what is missing and where I can go to broaden my understanding?

  2. It's clear to me how to work with the vertical size but the horizontal size is a mystery to me. I've seen someone write that it's based on the aspect ratio. How do I ensure that the game will be correct no matter what resolution display? I feel like it needs a script of some sort to adjust the horizontal measurements based on the current resolution, I know C# but I'm not sure what I need to adjust to accomplish this.

  3. If my understanding of the setting of the orthographic camera size is not correct, can you please explain where I am wrong and the correct procedure?

Thank you to anyone who takes the time to read and/or answer my question. I've made a decent number of games from scratch in pygame and even a game in Unity (A 2D shooter at that!) but pygame is 2D by design and because I didn't release the 2D shooter I didn't even mess with the resolution/orthographic size at all since it was only played on my personal monitor. This pixel perfect effect is really tricky for some reason because it really seems simple yet when I load up my background texture, make a material out of it, and attach it to the mesh renderer component it is never the size I need it to be.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by robertbu · Aug 06, 2013 at 08:03 PM

1) The mesh will hold any size you want. So if you scale it to (2,2,2), then something 128 x 128 will display pixel perfect (given your other settings).

2) The aspect ratio of your game will be Screen.width/Screen.height. So for 1024 x 768 it will be 1.3333. So if your screen is 12 units high it will be 16 units wide. As resolution changes, the width will change but not the height. So how you handle this will be game specific.

Comment
Add comment · Show 3 · 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 benarceneaux · Aug 06, 2013 at 08:18 PM 0
Share

robertbu: So I got around my problem by changing the scale of the quad I created (1x1 in Blender) to x: 16 and y: 12, my ortho size is 6 and I've changed my resolution to 640 x 480. So, correct me if I am wrong, my background texture I created is 640 x 480 pixels therefor if I attach this texture to my quad scaled to x: 16 and y: 12 I should have 640 pixels horizontal and 480 vertical correct?

And each one of my Unity world units will be 40 x 40 pixels? That seems wrong or just unusual for some reason, I'm not really understanding why but I thought that I could get the size in pixels of world units by dividing the vertical resolution by the ortho size * 2...

avatar image robertbu · Aug 06, 2013 at 08:42 PM 0
Share

All your calculations are correct. Not sure what you are seeing that make you think they are not. $$anonymous$$ake sure your camera is at (0,0,0). Note there is a CreatePlane script that would allow you to create a plane of any specific size and in either a vertical or horizontal orientation in the Unity editor here:

http://wiki.unity3d.com/index.php?title=CreatePlane

avatar image benarceneaux · Aug 06, 2013 at 08:53 PM 0
Share

Okay, I think I'm satisfied with what I've got so far. Thank you!

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

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Clamp a player to the edge of screen when the resolution changes 1 Answer

Can anyone help me how to remove this blurness from the road 1 Answer

How to REALLY change resolution 1 Answer

Dynamic Resolution for Desktop 2048.4 LTS Backport 0 Answers

Selecting Units within GUI.Box 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