Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Full Screen on Window Store App on 8.1 and 10

Discussion in 'Windows' started by van_ustwo, Sep 8, 2015.

  1. van_ustwo

    van_ustwo

    Joined:
    Jul 10, 2012
    Posts:
    82
    How do launch my game in full screen on WSA on Windows 8.1 or 10.

    My set up.
    Unity 5.1.2 or 5.2. Windows 10 + Visual Studio Community

    1. Create empty project.
    2. Build Windows Store App and launch in VS.
    3. Notice the game runs in Windowed and not full screen.
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,663
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    You can also use UnityEngine.Screen.SetResolution() API with fullscreen parameter set to true, but ultimately user can still get the application out of fullscreen - you cannot prevent it.
     
  4. DominoOne

    DominoOne

    Joined:
    Apr 22, 2010
    Posts:
    433
    Or you can simply set Screen.fullScreen = true;

    On the other hand, it seems that Microsoft wants Windows 10 games and apps to be able to run in windowed mode, so what you should probably do is add a "full screen on/off" button somewhere in your settings. Like in good old games :)

    You could maybe also make a screen blocking overlay, which says "go to full screen" (and a button that turns full screen on) if it's not in full screen. But I'm not sure if Microsoft would approve this.
     
  5. chandu125

    chandu125

    Joined:
    Sep 6, 2013
    Posts:
    33
    Hi,
    Anyone integrate video interstitial ads which are released recently by Microsoft on windows 8.1 universal application?
    if any one knows please reply to this one.
     
  6. CyberAngel

    CyberAngel

    Joined:
    Oct 4, 2014
    Posts:
    125
    Is there any reason Unity doesn't do this. Windows 10 Store games are now able to switch to full screen, like Fable Legends for example. It opens full screen window and then opens full screen, which I have tried to mimic what Fable Legends does, but it will always be small Window (or last set if already run previously) then switch to full window screen.

    While I understand the logic behind what MS are trying to do, Unity 3D on the other hand is just making our lives harder.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    There's nothing preventing you from doing this in generated VS solution on startup:

    Code (csharp):
    1. ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;
    Let's say, in App class constructor. It will make the app start up in fullscreen.

    There's one gotcha: if you have debugger attached, the window will still open up as windowed at first for a few seconds, while debugger is loading symbols and doing other stuff. That will not happen if you launch manually without a debugger.
     
  8. CyberAngel

    CyberAngel

    Joined:
    Oct 4, 2014
    Posts:
    125
    But, wouldn't it be nice for a check box in player settings that wrote that code for you! I prefer to see Unity be proactive in making simple things like this easier, rather than having to make changes to the code. Especially when one can simplay delete that and create from fresh.
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    I suppose it makes sense. I'll see what we can do.
     
    Last edited: Oct 25, 2015
  10. CyberAngel

    CyberAngel

    Joined:
    Oct 4, 2014
    Posts:
    125
    That would be great if something could be done.
     
  11. CyberAngel

    CyberAngel

    Joined:
    Oct 4, 2014
    Posts:
    125
    Just out of curiosity, for the time being where in the generated D3D code do I stick what you suggested?
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    Inserting it as a first thing into Main function would do.
     
  13. CyberAngel

    CyberAngel

    Joined:
    Oct 4, 2014
    Posts:
    125
    That's why I asked and has anyone actually tried it? Because all I get is the ApplicationView is doesn't exist in the current context.
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    I tried it. You need "using namespace Windows.UI.ViewManagement" - I thought VS would suggest you that.
     
  15. CyberAngel

    CyberAngel

    Joined:
    Oct 4, 2014
    Posts:
    125
    It might do, just I am still getting the hang of VS. I spent most of my career in the Java space.

    Anyway I did end up working it out, by googling it.

    However, I ran into an issue that I can't work out. If I modify the app.cs file and build from there I have no issues in it working in full screen, but if I rebuilt it from Unity the code is missing from the app.cs file. But it still compiles and runs in full screen mode as if the that snippet of code is there. This became problematic as I wanted to focus away from the full screen for now and couldn't find how to bring it back to a window.

    Is there some form of caching going on here that I may need to be aware of?
     
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    I actually don't know, it might be the system remembering the application preference. You could do this to force it windowed:

    Code (csharp):
    1. ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
     
  17. CyberAngel

    CyberAngel

    Joined:
    Oct 4, 2014
    Posts:
    125
    I was thinking the same thing, so I made it a window while the game was running and then closed it down as normal behaviour is to then to open last window size. But it always opens full screen as if that code was being run to make it full screen.
     
  18. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    I've experiemented with this recently, and found that all you really need to do is add:

    ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;

    to app.xml.cs in the App() constructor.

    this will launch in fullscreen mode; however, the user has the ability to change this and once it 'has' been changed, there is no simple way to force it back as this is controlled in the XAML front-end. You would need to use the bridge between Unity and XAML to provide an option in-game mode to switch it back if the user changes it. (which I have not done myself yet).
     
  19. CyberAngel

    CyberAngel

    Joined:
    Oct 4, 2014
    Posts:
    125
    Not sure if this was directed at me or not, but I am not using the XAML compiling in any way shape or form.
     
  20. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    You can switch to fullscreen at runtime using Screen.SetResolution unity API.
     
    tswalk likes this.
  21. antonsem

    antonsem

    Joined:
    Dec 13, 2012
    Posts:
    17
    Ok so I declared "using Windows.UI.ViewManagement;" and tried to use "ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen;" in App() constructor but it says "ApplicationView does not contain definition for 'PreferredLaunchWindowingMode'.". Also using Screen.fullScreen or Screen.SetResolution() does not work.

    I built my project from unity 5.2.2 in windows 10 with universal 8.1 apk.
     
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    ApplicationView.PreferredLaunchWindowingMode is only available when targeting Universal 10 SDK. Unfortunately, I'm not sure if there is a way to do it from Windows 8.1 app.

    Before windows 10, all windows store applications started in fullscreen, and they didn't have a choice to do it in any other way, so there's no API for it.

    With Windows 10, Microsoft made the default for all apps to start in windowed mode, and that kinda sucks for games. They also added API for Windows 10 apps to opt in for fullscreen.

    So the only way to solve it I think is to compile your application twice: once for Windows 8.1, and once for Windows 10, and submit both packages under single application entity in the store. That way, people with Windows 8.1 will automatically download the 8.1 version, and people with Windows 10 will download the Windows 10 version.
     
  23. antonsem

    antonsem

    Joined:
    Dec 13, 2012
    Posts:
    17
    :/ that is bad. Well, I'll do as you suggest than. Thank you.
     
  24. Walki

    Walki

    Joined:
    Jan 14, 2013
    Posts:
    1
    I found a solution on the internet (It's a rather dirty workaround but it works).
    Just wanted to drop by and tell everybody who will be searching the future (I know this thread is 2 months old):

    Code (csharp):
    1. namespace ClassLibrary1
    2. {
    3.   public class Class1
    4.   {
    5.    public static void cast()
    6.    {
    7.     var currentView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
    8.     currentView.TryEnterFullScreenMode();
    9.    }
    10.   }
    11. }
    Add this code to your App.xaml.cs

    Code (csharp):
    1. using System.Reflection;
    2.  
    3. #if UNITY_WSA
    4.   public void fullScreen()
    5.   {
    6.   string assemblyInfo = "ClassLibrary1";
    7.  
    8.   var m = Assembly.Load(new AssemblyName(assemblyInfo));
    9.  
    10.   Type t = m.GetType("ClassLibrary1.Class1");
    11.   object o = Activator.CreateInstance(t);
    12.   MethodInfo mi = o.GetType().GetTypeInfo().GetDeclaredMethod("cast");
    13.  
    14.   mi.Invoke(o, null);
    15.   }
    16. #endif
    I recommend adding the method call at the bottom of InitializeUnity();

    Code (csharp):
    1. #if UNITY_WSA
    2.   fullScreen();
    3. #endif
    Source: https://social.msdn.microsoft.com/F...w81vbautomatic-full-screen-in-windows-81-apps
     
  25. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    You can write the same code directly, no need for separate library and reflection.
    However, note that TryEnterFullScreenMode() does not guarantee that you will enter fullscreen. Unity calls that same API internally.