Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Connodore64 · May 11, 2020 at 06:54 PM · build-errorfullscreenwindowed

Toggling between fullscreen, maximized window, and smaller window

I can't seem to get my game to switch to a maximized window where the window is docked to the top of the screen. I'm currently using a UI Slider to choose between these 3 options. My game is a 2D, top-down space shooter, so I want the game to not reveal any more of the level, so I have the window unable to be resized by dragging the sides, but I still want to support some screen variations. Currently I have a system to switch between Fullscreen, a 1920x1080 non-fullscreen window, and a 1024x576 window:

     public void setScreenSize(float size) {
             switch (size) {
                 case 0:
                     Screen.fullScreen = true;
                     print("FULLSCREEN");
                     break;
                 case 1:
                     Screen.SetResolution(1920, 1080, false);
                     print("MAXIMIZED WINDOW");
                     break;
                 case 2:
                     Screen.SetResolution(1024, 576, false);
                     print("WINDOWED");
                     break;
                 default:
                     Screen.fullScreen = true;
                     break;
             }
         }
 
 

This code works, but I'm not a fan of the 1920x1080 window as it can be moved around, part of the screen is cut off, and it doesn't match everyone's resolution. I tried to change the player's settings through UnityEditor.PlayerSettings.fullscreenMode to change it, but that didn't let me build it:

     public void setScreenSize(float size) {
             switch (size) {
                 case 0:
                     Screen.fullScreen = true;
                     print("FULLSCREEN");
                     break;
                 case 1:
                     UnityEditor.PlayerSettings.fullScreenMode = FullScreenMode.MaximizedWindow;
                     print("MAXIMIZED WINDOW");
                     break;
                 case 2:
                     Screen.SetResolution(1024, 576, false);
                     print("WINDOWED");
                     break;
                 default:
                     Screen.fullScreen = true;
                     break;
             }
         }
 

My error is: "Assets\Scripts\settingsMenu.cs(75,17): error CS0234: 'PlayerSettings' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)"

Why does UnityEditor.PlayerSettings.fullScreenMode = FullScreenMode.MaximizedWindow; not work? Is there anyway I can maximize the window through my script? Thank you in advance.

I've also tried Screen.fullScreenMode = FullScreenMode.MaximizedWindow; and that just glitched out a ton.

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 FZ_Applications · May 11, 2020 at 08:16 PM

You can't use UnityEditor in built games. The UnityEditor namespace basically only for writing editor extensions. Try this code:

 Screen.SetResolution(1920, 1080, FullScreenMode.ExclusiveFullScreen, 60);
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 Connodore64 · May 12, 2020 at 12:31 AM 0
Share

I tried this, but the window was fullscreen and not a maximized window. I tried using the other options like FullScreen$$anonymous$$ode.$$anonymous$$aximizedWindow (which doesn't make sense as to why this one doesn't work), FullScreen$$anonymous$$ode.Windowed, and FullScreen$$anonymous$$ode.FullScreenWindow, but none of them do what I wanted, either being a small window or fullscreened. Is there any other way that this can be done?

avatar image FZ_Applications Connodore64 · May 12, 2020 at 07:18 AM 0
Share

I see, FullScreen$$anonymous$$ode.$$anonymous$$aximizedWindow also doesn't work in my game.
Another approach to your problem might be to overlay black boxes over the area you want to hide and to move them with the camera.

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

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

Linux build - fullscreen to windowed 2 Answers

Just installed Unity, cannot see menu bar 1 Answer

How can I enter fullscreen mode in a very low resolution? 0 Answers

is it possible to have a windowed app display in the 1st monitor and full screen app display in the 2nd monitor? 1 Answer

Resolution dialog has no influence. 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