Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Universal App: Distinguishing between Phone and Desktop

Discussion in 'Windows' started by Starsman Games, Sep 4, 2014.

  1. Starsman Games

    Starsman Games

    Jan 30, 2011
    I am having a few issues with a universal version of my app.

    First, I would like to determine if i am running or a phone or on the desktop. I want to quit the game if the Escape key (back) is hit only while in the phone, for instance.

    Another issue I am having is that for some reason the mouse cursor is being displayed on the phone.

    And the final issue: the phone is accepting any orientation as valid, this being a side scroller game means that everything really gets messed up in portrait mode. How can I restrict rotation in Windows Store builds? In Windows Phone i was just able to select the valid orientations under Resolution and Presentation. Resolution and Presentation seems to be empty under Windows Store Player Settings.

    Thanks in advance and sorry if this has been asked before, if it was, my search-fu failed me.

    Edit: figured how to restrict orientation from within Visual Studio so that is out of the way.
    Last edited: Sep 4, 2014
  2. Tautvydas-Zilys


    Unity Technologies

    Jul 25, 2013

    you can use #if UNITY_WP_8_1/#endif define which will evaluate to true when running on the phone, while "#if UNITY_METRO_8_1" will evaluate to true only when running on Windows.

    The cursor issue may be bug - could you report it? I suppose you could still workaround it by disabling the cursor from code when you detect it's running on the phone.

    You can restrict the application rotation in the application manifest which is created in exported Visual Studio solution.