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

How to set focus to the player window?

Discussion in 'Windows' started by AlexYak, May 11, 2014.

  1. AlexYak

    AlexYak

    Joined:
    May 11, 2014
    Posts:
    7
    We're working on the educational app (Windows 8.1 Store app) which is using Unity to display interactive exercises for students. When the unity gets shown in the app the scene doesn't get an input focus. The only way to get it back is temporary switch to a start or a desktop and then back. How can we set the focus programmaticly?
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Looke like an issue with independent input source. Try to disable it.
     
  3. AlexYak

    AlexYak

    Joined:
    May 11, 2014
    Posts:
    7
    I've tried to add:

    appCallbacks.AddCommandLineArg("-disable-independent-input-source");
    appCallbacks.AddCommandLineArg("-disable-low-latency-presentation-api");

    It still doesn't fix the issue.
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Which version of Unity do you use?
    And how do you launch an application (dual monitor, split screen)?
     
  5. AlexYak

    AlexYak

    Joined:
    May 11, 2014
    Posts:
    7
    We're using the 4.3 version.

    The application is launched full screen on a tablet device. The Unity is not hosted on the first (main) page. We navigate to it at some point in the app.

    Thanks... Alex
     
  6. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,658
    A blind guess, try calling UnitySetInput(0), UnitySetInput(1) from AppCallbacks

    I am not actually sure that scenario you're describing is supported.

    You could fill a bug
     
  7. AlexYak

    AlexYak

    Joined:
    May 11, 2014
    Posts:
    7
    Hi Tomas1956,

    At which point I can call into these?
    I am getting Win32 exception when calling it before InitializeD3DXAML.

    Thanks... Alex
     
  8. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    UnitySetInput() is for disabling and reenabling input routing to Unity app when it's already running, so you shouldn't call it before initialize.
    It should be safe to call these after extended splash screen is removed.
    BTW, what kind of exception do you get. Perhaps we should fix it to throw something meaningful?
     
  9. AlexYak

    AlexYak

    Joined:
    May 11, 2014
    Posts:
    7
    OK, so I've tried to call it after the splash is removed, put it in the DispatcherTimer, etc... The fist call to UnitySetInput(false) just never returns for me and locks everything up.
     
  10. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    Are you calling from UI thread? UnitySetInput() must be called from UI thread, if you're on other thread, use AppCallbacks.InvokeOnUIThread().
     
  11. AlexYak

    AlexYak

    Joined:
    May 11, 2014
    Posts:
    7
    Yes I am calling it from the UI thread. I even tried to call it with AppCallbacks.InvokeOnUIThread() with the same result.

    Thanks... Alex
     
  12. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,627
    In that case please report a bug.
     
  13. AlexYak

    AlexYak

    Joined:
    May 11, 2014
    Posts:
    7
    Bug report has been submitted.