• 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
2
Question by Tyler Alvis · Jan 16, 2011 at 04:37 AM · fullscreen

How to script a full screen button?

I was wondering how to script(prefably in javascript) a full screen button, so if you click f the game will become full screen. If you could tell me how do that, that would be great!

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

4 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Jessy · Jan 16, 2011 at 04:52 AM

http://unity3d.com/support/documentation/ScriptReference/GUI.Button.html

http://unity3d.com/support/documentation/ScriptReference/Screen-fullScreen.html

http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html

Comment
Add comment · Show 8 · 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 Tyler Alvis · Jan 16, 2011 at 05:16 AM 0
Share

I tryed this: f(Input.Get$$anonymous$$eyDown("f")){ Screen.fullScreen = !Screen.fullScreen;} and it didn't work, i don't want a GUI button i want when i press f or something it will become fullscreen

avatar image Jesse Anders · Jan 16, 2011 at 06:45 AM 0
Share

You'll have to provide more information than 'it didn't work'. Also, Unity already has dedicated keyboard shortcuts for toggling between windowed and fullscreen modes.

avatar image Tyler Alvis · Jan 18, 2011 at 12:41 AM 0
Share

How about, I clicked f and nothing happened?

avatar image Jessy · Jan 18, 2011 at 03:07 AM 0
Share

Are you trying it in the Editor? It won't work there. Otherwise, the only thing wrong with your code is that it's missing an "i" in "if", but I assume you just copied/pasted poorly.

avatar image Tyler Alvis · Jan 19, 2011 at 01:35 AM 0
Share

it will only work when i export it?

avatar image ForeignGod Tyler Alvis · Feb 15, 2016 at 01:57 PM 0
Share

That's right.

Show more comments
avatar image
0

Answer by Petey.du · Jan 24, 2011 at 04:09 AM

I have also noticed a problem with trying to go full screen. I have the following code in the Update function:

if(Input.GetButtonUp("Fullscreen Toggle")) { Screen.fullScreen = !Screen.fullScreen; Debug,Log("Fullscreen: " + Screen.fullScreen); }

I get the Debug.Log message with every press of the key, but the message always returns 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
avatar image
0

Answer by Skarard · Mar 13, 2015 at 12:28 AM

It's a little late but for anyone else that is interested the reason it returns false is that you set it false with:

 Screen.fullScreen = !Screen.fullScreen;  

To enter fullscreen:

 Screen.fullScreen = true;

Solution Example:

 if (Input.GetButtonUp("Fullscreen Toggle")) { 
     if (!Screen.fullScreen) {
         Screen.fullScreen = true;
     } else {
         Screen.fullScreen = !Screen.fullScreen;
     }
     Debug.Log("Fullscreen: " + Screen.fullScreen); 
 }
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 Mazxz · Feb 15, 2016 at 01:38 PM

Or just do that:

using UnityEngine; using System.Collections;

public class screenFull : MonoBehaviour {

 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
 
 }
 void OnGUI()
 {
     if (GUILayout.Button("FullScreen"))
         Screen.fullScreen = !Screen.fullScreen;
 }

}

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Full Screen Web Player? 7 Answers

Fullscreen problem with resolution 1 Answer

how to run external fullscreen exe file on unity ? 1 Answer

How to Play Your Game Fullscreen on Different Resolutions 1 Answer

Full Screen Get smaller when i actived it 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