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 buxton4life · Nov 10, 2012 at 09:59 PM · camera2diosresolution

Orthographic Static 2D Background - IOS/Iphone 3,4 & 5

Does any man, women or child now how I would go about setting a simple 2D background that doesn't move but adapts to its screen resolution? Iphone - 320*480,640*960, 640*1136? (Portrait)

I know there script that asks if(Screen.width == the iphone specified){ }

but is there a simpler way of doing this kind of like a guiTexture set to 1, 1, 1 which adapts to its screen size?

Help would be saaaaawweeeeet! thanks!

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
1

Answer by IronFurball · Nov 10, 2012 at 11:09 PM

There's a really simple way of doing this.

 OnGUI()
 {
     GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),yourTexture);
 }

another way om making sure your game fits all resolutions is by designing your gui for a specific resolution(by example 800 * 600), and then using GUIMatrix, which automatically scales everything made with unity's OnGUI function.

now, i don't know exactly how GUIMatrix works but this should do the trick:

 var horizRatio = Screen.width / 800;
 
 var vertRatio = Screen.height / 600;
 
 GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3 (horizRatio, vertRatio, 1));

Keep in mind when using GUIMatrix that your designing for a specific resolution and you dont have to use calculations such as Screen.width/2 + offset or something like that.

instead just give the exact position values and size values, the GUIMatrix wil do the rest.

Hope this helped !:)

Comment
Add comment · Show 2 · 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 buxton4life · Nov 11, 2012 at 12:32 AM 0
Share

sounds good to me, i glanced over GUI matrix once but I think i'll give it another go..I was warned about its unreliability with ios though as it doubles the draw cell count...and would the GUI not place itself in front of the actual gameobjects etc or can you set its z-index??

avatar image IronFurball · Nov 12, 2012 at 11:40 AM 0
Share

im terribly sorry, i didnt think this through enough, the gui is indeed in front of everything as far as i know. im quite busy at the moment but maybe this can help you futher: http://answers.unity3d.com/questions/9729/how-can-i-display-a-flat-background-2d-image-not-a.html

again im verry sorry, i guess i wasnt paying enough attention :P

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

10 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

Related Questions

Resolution problem!!! 2 Answers

Camera viewport should be square and pixel-perfect, regardless of player aspect ratio. 0 Answers

Problem with Camera.ScreenToWorldPoint() on 2D Multiplayer 0 Answers

How to letterbox the screen and have pixel perfection in a 2d game 0 Answers

IPhone is zoomed in/out depending on which model 0 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