Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

UnityEngine.WSA.Application.windowActivated event not called when compiled using IL2CPP

Discussion in 'Windows' started by smenyhart, Apr 16, 2019.

  1. smenyhart

    smenyhart

    Joined:
    May 6, 2016
    Posts:
    35
    I was able to get this event before while using the NetCore backend in Unity 2018, but now that I'm forced to use IL2CPP in Unity 2019, this event no longer seems to be triggered. The C++ generated code for the event registration and handling is there, but I never get the event.

    Code (CSharp):
    1.  
    2. public class HoloLensExternalDataInput : MonoBehaviour
    3. {
    4.     // Use this for initialization
    5.     void Start ()
    6.     {
    7.         Debug.Log("HoloLensExternalDataInput-Start");
    8.         UnityEngine.WSA.Application.windowActivated += Application_windowActivated;
    9.     }
    10.  
    11.     private void Application_windowActivated(UnityEngine.WSA.WindowActivationState state)
    12.     {
    13.         var arguments = UnityEngine.WSA.Application.arguments;
    14.         Debug.Log("Application_windowActivated - arguments: " + arguments);
    15.     }
    16. }
    17.  
    I see the Log statement for the Start method, but never the Log statement for the actual event.

    I do see the built in log statements when running the app in debug mode:
    [32.297251 / 41.280151] - OnWindowActivated event - Deactivated.
    [1.585198 / 42.865348] - OnVisibilityChanged event - Hidden.
    'JTViewer.exe' (Win32): Loaded 'C:\Windows\System32\msxml6.dll'. Cannot find or open the PDB file.
    [18.973996 / 61.839344] - OnHolographicWindowActivated event - CodeActivated.
    [0.322481 / 62.161825] - OnVisibilityChanged event - Visible.
    [0.020812 / 62.182637] - OnHolographicWindowActivated event - Deactivated.
    [0.007574 / 62.190210] - OnWindowActivated event - CodeActivated.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,515
    This is a bug in our code :(. Could you file a bug report?

    In the mean time, you can work around it by creating a file named "link.xml" with this content:

    Code (csharp):
    1. <linker>
    2.        <assembly fullname="UnityEngine.CoreModule">
    3.                <type fullname="UnityEngine.WSA.Application" preserve="nothing">
    4.                       <method name="InvokeWindowActivatedEvent"/>
    5.                </type>
    6.        </assembly>
    7. </linker>
    And then putting it inside any folder in your project.
     
  3. smenyhart

    smenyhart

    Joined:
    May 6, 2016
    Posts:
    35
    Thanks for the workaround. I have submitted a bug report
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    6,515
    What's the bug number?
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,035