Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 G3R1 · Jun 04, 2017 at 04:54 PM · resolutionscreenscene-loadingchangeawake

How to call Screen.SetResolution() only once before the first scene starts loading ?

Hi,

I am trying to set the screen resolution for mobiles before the game starts loading the first scene. I tried puting the Screen.SetResolution() on Awake() method of the singleton gameobject that i use on every scene that loads asynchronously, but there seems to be a problem when i open the game on android phones because of the transition of the screen change that happens during the call of Screen.SetResolution(). The transition only happens for less than 200 ms but users can see that and looks like a bug and it is not that beautiful. Also, when the game opens, the first scene that loads is a scene that has the script to load every other scene that is selected during the game by the user and is loaded asynchronously showing a progress bar. I tried using a coroutine with "yield return new WaitForEndOfFrame()" in order to hide the transition from being displayed and delay the loading of the first scene and it works fine but the codes I am using for this are not on the persistent gameobject script. They are in the first scene which gets destroyed everytime after the selected scene is loaded. I stored a bool variable and set it to false on the persitent scene and called that when the Screen.SetResolution() coroutine was executed in order to prevent the resolution being set everytime a new scene is selected by the user. All works fine but i just wanted to know if there is a better way to make all of this inside the persistent gameobject script or the singleton i am using to control my game.

Here you have the code delays scene loading until the Screen.SetResolution() is finished :

 void Start()
     {
         if (!GameControl.control.screenResolutionIsSet) {
             StartCoroutine ("LoadWhenScreenResolutionIsSet");
         } else {
             //If Screen.SetResolution() was executed once there is no need to repeat that...
             LoadNextScene ();
         }
     }
 
     private IEnumerator LoadWhenScreenResolutionIsSet()
     {
         Screen.SetResolution(720, 1280, true);
         yield return new WaitForEndOfFrame ();
         yield return new WaitForEndOfFrame ();
         yield return new WaitForEndOfFrame ();
         LoadNextScene ();
         GameControl.control.screenResolutionIsSet = true;
     }
 public void LoadNextScene()
     {
                //Here I load selected scenes asynchronously....
     }

If anyone has an idea please share it. Thank you, Gerald.

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 JonPQ · Jan 16, 2018 at 12:02 AM

Make a setup scene... have that be the first scene, then make that scene load the next scene

hiding the glitch... fade screen to black or other plain color before switching... crap solution, but works.

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

68 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 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 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

how I can change the screen resolution in real time? 1 Answer

How to make game recognise Screen resolution on startup 1 Answer

How to Change Screen Resolution in game 2 Answers

Can I customize the resolution window that appears at the start of my executable? 2 Answers

Changing screen resolution is cutting the very edge of my screen off 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