How can I make full screen in unity editor's game screen?

currently I am making 1280 * 768 resolution game.

But if I use 1366 * 768 laptops (mostly be this), and if I hit play button for testing in unity editor, game screen does not become full screen mode even if I press the right-above’s full screen button.

How can I see unity editor’s game screen as a full screen?

I really need this function.

Checking the [Maximize on Play] does not work.

At some point you will need to learn to use the script reference yourself.
It has a search option and works very well.
http://unity3d.com/support/documentation/ScriptReference/Screen.SetResolution.html

2 Likes

I input one line to my code but still it does not work.

Screen.SetResolution (1280, 768, true);

I mean not standalone or webplayer, but unity editor itself’s game screen. so that I can test frequently in full screen mode even at 1366 * 768 laptops.

That’s actually a good question, I’ve run into the same situation myself. I’ve got a dual screen system so I just grab the “Game” view window and drag it to the second monitor and stretch it to the size I want. You could probably write an editor script that would do the same thing. Otherwise, you’ll have to build a stand alone and run it to view it at the fullscreen resolution. If there’s another (better) way to do it I’m all ears. :wink:

so how I can resize the game screen’s border to very thin or just delete the border itself to make it looks like full screen.?

I don’t know if that’s possible. What I typically do is drag the game view window to a screen that is larger than the size I need and then manually drag the corners until it’s roughly the size I need.

I am saying in the case of I am outside and I have only 1366 768 laptops.

Right, I understand your question. I don’t know if that’s possible to do with an editor script. You may be able to drag and stretch the window so it’s contents fill the vertical height of the screen. If not, you may have to preview by building a stand alone. I don’t know of any good / easy solution to the problem, that’s why I said it was a good question. :wink:

You can’t (maximize on play is the closest you can get), but it shouldn’t make any difference. All you need is the aspect ratio, not the exact number of pixels. You’re using a 3D engine, so that usually means the game should run in any resolution. Ideally you should make it run in any aspect ratio too.

–Eric

1 Like

True, except on those projects which require a specific screen resolution to be supported, which is what I’m thinking the OP is asking about. Ideally in that particular situation you have the monitor that the project will be playing on for design and testing purposes.

Actually, I really want to do what you say. But I already wrote much gui as, GUI.Button(Rect(100, 100, 50, 50),

Then when I play and if I size down the screen, whole gui seems crashed and cutted out.

So I searched about how to set this seems right at low resolution, not read whole answers, but I saw the method of matrix4x4.TRS.

But this does not work at all.

So I want to resize the GUI elements too when I play it at low resolution.

So then is it enough to do like this? GUI.Button(Rect(Screen.width/2-50,)

So whole GUI’s Rect’s standard position must be The middle position of screen? (Screen.width/2, Screen.height/2)?

Same problem. I build and run every single time I need to test something. Even on a i7 is a pain. May be the developers of Unity hears us prayers! :slight_smile:

1 Like

Hello everyone.

I know this thread is a bit old, but I found a script that does what you are looking for.

https://www.reddit.com/r/Unity3D/comments/2lymim/full_full_screen_on_play_script_freebie_for/

I use it because I need to video record the screen on portrait mode and it helped wonders. It does work full screen, however, if you do record the video, it will record with the Game window top bar.

Hope this helps.

2 Likes

the script is nice but it always changed my ‘standalone’ resolution to ‘free aspect’ (+ it closes the game window too often) - here’s my cleaned up version that behaves much nicer

using UnityEditor;
using UnityEngine;
using System.Collections.Generic;

[InitializeOnLoad]
public class FullscreenPlayMode : MonoBehaviour {
   //The size of the toolbar above the game view, excluding the OS border.
   private static int tabHeight = 22;

   private static Dictionary<string, Vector2> settings = new Dictionary<string, Vector2> {
      {"mnml", new Vector2(1920,0)} // sharing your code? offsets go in here!
   };

   static FullscreenPlayMode() {
      if (settings.ContainsKey(System.Environment.UserName)) {
         EditorApplication.playmodeStateChanged -= CheckPlayModeState;
         EditorApplication.playmodeStateChanged += CheckPlayModeState;
      }
   }

   static void CheckPlayModeState() {
      // looks strange, but works much better!
      if (EditorApplication.isPlaying) {
         if (EditorApplication.isPlayingOrWillChangePlaymode) {
            FullScreenGameWindow();
         } else {
            CloseGameWindow();
         }
      }
   }

   static EditorWindow GetMainGameView() {
      EditorApplication.ExecuteMenuItem("Window/Game");
      System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor");
      System.Reflection.MethodInfo GetMainGameView = T.GetMethod("GetMainGameView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
      System.Object Res = GetMainGameView.Invoke(null, null);
      return (EditorWindow)Res;
   }

   static Rect orig;
   static Vector2 min;
   static Vector2 max;

   static void FullScreenGameWindow() {
      EditorWindow gameView = GetMainGameView();

      Rect newPos = new Rect(0, 0 - tabHeight, Screen.currentResolution.width, Screen.currentResolution.height + tabHeight);
      newPos.position = newPos.position + settings[System.Environment.UserName];
      orig = gameView.position;
      min = gameView.minSize;
      max = gameView.maxSize;

      gameView.position = newPos;
      gameView.minSize = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height + tabHeight);
      gameView.maxSize = gameView.minSize;
      gameView.position = newPos;

   }

   static void CloseGameWindow() {
      EditorWindow gameView = GetMainGameView();

      gameView.position = orig;
      gameView.minSize = min;
      gameView.maxSize = max;
      gameView.position = orig;
   }
}
4 Likes

For me it works like:

Screen.SetResolution(1600, 800, true);

Before start the scene, go to Game tab and toggle Maximize on play
If you didn’t see effect - try toggle Maximize on play several times.

Hey @mnml , just thought I’d point out your delegate gave me a small error. It should be:

static void CheckPlayModeState( PlayModeStateChange state )
{
    ...
}

I may be wrong, but it seems like it fixed it for me.

the code of @mnml seems to work, but only a few times. After a couple of times starting the game preview, the windows disappears completly and Ive got some “Scene out of view-frustrum” errors. To resolve this, I need to remove the script, restart the Unity (or sometimes Windows) and then close and open the game preview window again.

Any idea, whats causing this?

I think my video could help you. You can change play mode screen to exactly your screen size without limiting the physical screen size. This is some undocumented stuff but it works for me.

isnt this more or less the same like mnml did, only with screenshot capability added?

And I need it for testing touchscreen-inputs. I have a dedicated touch-screen on which I test everything. And the inputs of the screen are not scaled down to the downscaled preview, so everything is misaligned during a preview (or I have to scale it up to 1x, but then the game-borders are hidden behind the preview-window-borders.

yes, look like. I’ve not read the whole thread. sorry