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 Joakim · Sep 02, 2014 at 11:33 AM · 2dheightwidthortographic

Pixels to units question

I have a background image for 2D adventure game which is 1024 x 307 in pixels. Pixels to units ratio is set to 100, meaning this image should be about 10 units x 3 units. But, somehow it becomes approximately 60 units wide and 25 units in height. How come ?

I get warning in the inspector on image size not beeing multiple by 4 so it cant be compressed in DXT format, could this be the problem ?

I want to be able to get image width in units, smth like widthInUnits = image.width / ratio (ration beeing 100 in this case), so i get 1024/100 = 10 Units, but in action my image turns out to be 60 units in width... i dont understand how this happnes, which ratio is used ?

I use ortographic camera.

EDIT:

I realized that my image is in fact 6668x2004, and that is what actually gets translated into units, 66 x 20 units, but when i import image into unity it asks me for the "max size" in import settings, that was set to 1024 so when i obtain image.width its 1024. I tryed changing maximum size to 4096 in import settings (which is max sizei can get), but still image.width returns 1024.

I dont understand how Unity actually uses 6668x2004 image dispite max size is set to 1024. And even if max size is set to 4096, image.width still returns 1024...

EDIT 2:

Ok it returns 4096 i was referencing wrong image in code sry

Now the question remains, why does unity use 6668x2004 image in spite of setting 4096 to be max allowed. Should i simply resize my original image to be 4096xSomthing, and never use larger images?

Comment
Add comment · Show 2
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 kacyesp · Sep 02, 2014 at 11:38 AM 0
Share

What do you mean by cca?

avatar image Joakim · Sep 02, 2014 at 11:43 AM 0
Share

cca == approximately

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by kacyesp · Sep 02, 2014 at 11:47 AM

Unity is most likely resizing your picture to a power of 2. 307 is an odd number so it's scaling it up pretty big, hence why your unity units is higher than you expected. If your image fits, put in a 1024 256 file, otherwise, use 1024 512.

Comment
Add comment · Show 11 · 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 Joakim · Sep 02, 2014 at 12:23 PM 0
Share

I edited my question, i realized that my image is in fact 6668x2004, and that is what actually gets translated into units, 66 x 20 units, but when i obtain image.width its 1024. I tryed changing maximum size to 4096 in import settings (which is max), but still image.width returns 1024

avatar image kacyesp · Sep 02, 2014 at 12:27 PM 0
Share

Did you hit the apply button after changing the max size?

avatar image Joakim · Sep 02, 2014 at 12:29 PM 0
Share

Edited again, was checking for different immage >.<, now its ok, it returns 4096 as set in import settings

avatar image kacyesp · Sep 02, 2014 at 12:39 PM 1
Share

The original image keeps its size. But the image used in your game will be compressed to the max size. It won't be compressed if it's smaller than the max size. And you'll have to combine images or downsize the image to get 6668x2000.

avatar image Joakim · Sep 02, 2014 at 12:50 PM 1
Share

Got it, thx man, now I dont know should I mark this answer as correct cos question "evolved" as i realised few things xD.

Still seems to me that Unity is not resizing my 6668 image to 4096, but i wont bother i ll split my big image into smaller ones

Show more comments

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

23 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Newbie question 2d positioning and moving 2 Answers

How to change the Width and Height in the script C#? (New Gui Unity 4.6 beta) 2 Answers

rect.Contains cant accept rects with a negative width and height? 4 Answers

Changing height of camera based on device aspect ratio. How? 0 Answers

[UNSOLVED] Get a GameObject width and height in pixels (JS) 3 Answers


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