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 spacelyjoe · Feb 15, 2014 at 12:01 AM · screendimensionsfit

How to lock the game screen to certain dimensions?

alt text

So I want my game view to ONLY show the background, none of the blue. Is there anyway it will automatically do this no matter what screen size it's on? Or if someone can send me a tutorial with this information would be awesome too.

screen.png (10.7 kB)
Comment
Add comment · Show 3
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 getyour411 · Feb 15, 2014 at 12:14 AM 0
Share

Are you asking about Screen.width and height?

avatar image spacelyjoe · Feb 15, 2014 at 02:14 AM 0
Share

I'm not sure, I want the camera to only be on the background, but not sure how to adjust the camera's xy's lol can't figure it out

avatar image spacelyjoe · Feb 15, 2014 at 02:25 AM 0
Share

Well I'm developing this for an itouch device, is there anyway I can just make it automatically change the screen width and height depending on the device but still keep all the content in between the screen dimensions?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by iamvishnusankar · Feb 15, 2014 at 02:28 AM

If you're bored of reading too much stuff and want some visual explanation. Check this out. This has pretty much everything you want

Live Training 28 Oct 2013 - Cameras

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 spacelyjoe · Feb 15, 2014 at 02:29 AM 0
Share

Cool, thanks.

avatar image
0

Answer by erick_weil · Feb 15, 2014 at 02:43 AM

if your bakcground is set OnGui() will only need to especify the width of background as Screen.widht and the height at Screen.height

but if your background is a plane gameObject:

the height is always the same, only manually drag the camera to look exactly at the top and botton corners

but.. the width is variable, you need or to resize the plane(as a child of the camera) in x-axis using a simple count: place a object at the top of the plane, and one at the botton; one at left and one at right.

#pragma strict var top : GameObject; var bottom : GameObject; var left :GameObject; var right : GameObject; var height : float; var width : float; var planewidth : float; function Start () { top = GameObject.Find("top").gameObject; bottom = GameObject.Find("bottom").gameObject; left = GameObject.Find("left").gameObject; right = GameObject.Find("right").gameObject; height = (top.transform.position - bottom.transform.position).y; planewidth = (left.transform.position - right.transform.position).x; width = (Screen.width*height)/Screen.height; transform.localScale.x = planewidth/width; } function Update () { height = (top.transform.position - bottom.transform.position).y; width = (Screen.width*height)/Screen.height; planewidth = (left.transform.position - right.transform.position).x; transform.localScale.x = width/planewidth; }

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 spacelyjoe · Feb 15, 2014 at 03:27 AM 0
Share

I don't understand what you're saying, is there anyway to just set the height and width of the orthographic camera to match that of an iPhone screen? And if not why not?

avatar image erick_weil · Feb 15, 2014 at 03:31 AM 0
Share

you are using a orthografic camera, lol, sorry for this. I tryed to scale the plane gameobject to match at the borders of an perspective camera.

avatar image spacelyjoe · Feb 15, 2014 at 03:48 AM 0
Share

So any idea what to do?

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

20 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

Related Questions

Resizable GUI box how to? 1 Answer

Window info not updating when moved 0 Answers

Objects to fit on the screen 2 Answers

Make an Orthographic Camera FIT in the screen, not FILL it. 0 Answers

How to make game fit all screen Size and Resolutions 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