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 Leon_SFS · Dec 11, 2013 at 01:42 PM · androidresolutionscreenandroid-manifest

screen resolution in android

Hi there
i have set custom manifest for my android game in unity
in manifest i use

 <supports-screens android:largeScreens="false" android:normalScreens="false" 
       android:smallScreens="false" android:resizeable="false" android:anyDensity="false" />


for disable streching my game to screen size.because when do strech or scaling to output size, the game is going to slow.
after disable strech my screen like this : alt text
my target is android device that show out put on monitor
i have the resolution : 1280 * 720
how can i set the camera or resolution or any thing else,to become my screen fit
i use unity 3.5.x
tnx 4 adv
and sorry 4 bad english

device-2013-12-11-152423.png (5.0 kB)
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

Answer by bilo-lwabona · Dec 11, 2013 at 04:07 PM

In Unity, the camera has various properties for the viewport. One of them is "pixelRect", which gives you the viewport in pixels.

Another is the property "rect" (in the Inspector of Unity's Editor it is called viewport rectangle). This property allows you to specify where on the screen the camera viewport appears and how much of the screen it should take up.

Note that "rect" is normalised. By default, the x & y position is set to 0, so the camera starts drawing from the corner. The width and height are both 1, which translates to 100% of the screen size.

To get your desired resolution (in Unity) you could do this for the width:

 // desiredWidth being your desired width, presumably 1280?
 camera.rect.width = desiredWidth * Screen.width;

And you could do the same for the height. To centre the screen you would obviously have to play with the x and y coordinates of the camera's rect and do some offsets using half the width/height for x/y respectively. Hope this answers your question.

Cheers

Bilo

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 Leon_SFS · Dec 12, 2013 at 09:34 AM 0
Share

it's dont make any different. my game is 2D.
and the picture i have posted is my tv output.the blue rect is my game. Screen.Width() says 480 !!but my tv width is 1280.

it's happen when i use that manifest line code.if i dont use that.game is fullScreen but it's very slow and not suitable. i think the scale process make it slow. game tested on phone and not slow! game is a texture on back and a plane that can move.and camera i going upside slowly.like RiverRaid Game!

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

17 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

Related Questions

Unity android cropped screen 1 Answer

Excluding android devices with resolution less than X 0 Answers

Game fills only one quarter of the screen, why? (Android) 1 Answer

How to scale my camera to fit all android and iOS screen sizes 1 Answer

Reading Screen Dimension in Android Immersive Mode 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