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 pl_bota95 · May 21, 2013 at 04:03 PM · variableresolutionscreendynamic

Variable Resolution

Hello!

How can i make my game change his resolution according to the computer it is played on, so it will be stretched on the screen. I am building for Web or Flash.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by randomuser · May 22, 2013 at 01:24 AM

It's not too clear what you are asking for here. The Unity game engine automatically handles most screen resolution changes by itself. The only thing you need think about is the unity GUI. You need to create your GUI elements in terms of Screen.width and Screen.height. So instead of screen coordinates (0, 980) to get a element of x 0 and y 3/4 of the way up a screen, you would use screen coordinates (0, Screen.height*.75).

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

Answer by FlameonStudio · Dec 26, 2017 at 07:11 PM

Well, this can be achieved with Screen.currentResolution, although if you're looking for a variable storing this, here's an example of something I found that works :) :

 using UnityEngine;
 
 public class Example : MonoBehaviour;
 {
 Resolution resolution = Screen.currentResolution;
 
 void Start ()
 {
 Debug.Log(resolution); //Prints: 1920x1080 @ 60hz (In my case, could be 1600 x 720 @ 30hz for ex.)
 }
 
 }

Although changing resolution? Alright. Let's use the same method as before.

     using UnityEngine;
     
     public class Example : MonoBehaviour;
     {
     Resolution resolution = Screen.currentResolution; //This time, we are storing multiple resolutions
     Resolution res1;
     Resolution res2;
 
     public bool useRes1; //These are used to pick from the 2 resolutions
     public bool useRes2;
     
     void Start ()
     {
     res1.height = 600;
     res1.width = 800;
 
     res2.height = 768;
     res2.width = 1024;
 
     if (useRes1)
     {
         Screen.SetResolution(res1.width, res1.height, false); //False can be changed to true if we are running fullscreen, but since you are running flash it's not required
     }
 
     if (useRes2)
     {
         Screen.SetResolution(res2.width, res2.height, false);
     }
     }
     
     }

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

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

15 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

Related Questions

Dynamically setting font size with respect to Screen Size 2 Answers

Reading Screen Dimension in Android Immersive Mode 1 Answer

Asset Variations for Different Mobile Screen Sizes 1 Answer

Max Resolution? Targeting 4320x5400 px... 1 Answer

Auto scaling GUI 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