Search Unity

How to run Unity app several time in UWP app

Discussion in 'Windows' started by unity_0PfXqw83o46aIg, Oct 12, 2018.

  1. unity_0PfXqw83o46aIg

    unity_0PfXqw83o46aIg

    Joined:
    Oct 12, 2018
    Posts:
    3
    Hi everyone,

    Is it possible to run several unity apps from UWP project code?
    I mean that I have Unity project builded as UWP application, and I want to use Unity application as a control several time, in different pages.

    I have two problems:
    1) I can't reset SwapChainPanel, when I do SetSwapChainPanel second time I get empty space in place whe should be Unity frame.
    2) I don't know and can't find the answer can I run Unity app two times at the same time and use two unity frames in one UWP page or not?

    If somebody can solve my problems It would be great.
    Thanks!

    P.S. I'm sorry for my maybe not very good english :)
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    You cannot run Unity app twice at the same time. You can, however, unload a Unity app using "Application.Unload()" and then initialize it from scratch again (recreating AppCallbacks, etc).
     
  3. unity_0PfXqw83o46aIg

    unity_0PfXqw83o46aIg

    Joined:
    Oct 12, 2018
    Posts:
    3
    Do you mean do
    Application.Unload();
    in Unity script and then just
    AppCallbacks = new AppCallbacks();
    ?

    I get exception when I use
    AppCallbacks = new AppCallbacks();
    second time, even after
    Application.Unload();
    .

    I suspect that I not exactly understand main idea.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Can you post the full code? What's the exception that you're getting? Which Unity version are you on?
     
  5. unity_0PfXqw83o46aIg

    unity_0PfXqw83o46aIg

    Joined:
    Oct 12, 2018
    Posts:
    3
    Yes, sure.
    Version of unity: 2018.2.11f1.
    With exception I have problem, I can't see what exception exactly I have. Visual studio just suggest me open different visual studio, but even after this I don't see details of exception.

    Code below.

    Unity script:

    Code (CSharp):
    1. using UnityEngine;
    2. using Application = UnityEngine.Application;
    3.  
    4. public class CubeBehaviourScript : MonoBehaviour
    5. {
    6.     private static bool _isNeedUnload;
    7.     private static RotationDirection _direction;
    8.  
    9.     public static void UnloadApplication()
    10.     {
    11.         _isNeedUnload = true;
    12.     }
    13.  
    14.     // Use this for initialization
    15.     void Start()
    16.     {
    17.         _isNeedUnload = false;
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.         if (_isNeedUnload)
    24.         {
    25.             _isNeedUnload = false;
    26.             Application.Unload();
    27.         }
    28.     }
    29. }
    App.xaml.cs:

    Code (CSharp):
    1. using Windows.ApplicationModel.Activation;
    2. using Windows.UI.ViewManagement;
    3. using Windows.UI.Xaml;
    4. using Windows.UI.Xaml.Controls;
    5. using Unity;
    6. using UnityPlayer;
    7.  
    8. // The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227
    9.  
    10. namespace Cube
    11. {
    12.     /// <summary>
    13.     ///     Provides application-specific behavior to supplement the default Application class.
    14.     /// </summary>
    15.     sealed partial class App : Application
    16.     {
    17.         public static AppCallbacks AppCallbacks;
    18.  
    19.         /// <summary>
    20.         ///     Initializes the singleton application object.  This is the first line of authored code
    21.         ///     executed, and as such is the logical equivalent of main() or WinMain().
    22.         /// </summary>
    23.         public App()
    24.         {
    25.             InitializeComponent();
    26.             SetupOrientation();
    27.         }
    28.  
    29.         /// <summary>
    30.         ///     Invoked when the application is launched normally by the end user.  Other entry points
    31.         ///     will be used when the application is launched to open a specific file, to display
    32.         ///     search results, and so forth.
    33.         /// </summary>
    34.         /// <param name="args">Details about the launch request and process.</param>
    35.         protected override void OnLaunched(LaunchActivatedEventArgs args)
    36.         {
    37.             InitializeUnity(args.Arguments);
    38.         }
    39.  
    40.         private void InitializeUnity(string args)
    41.         {
    42.             AppCallbacks = new AppCallbacks();
    43.             ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;
    44.  
    45.             AppCallbacks.SetAppArguments(args);
    46.             var rootFrame = Window.Current.Content as Frame;
    47.  
    48.             // Do not repeat app initialization when the Window already has content,
    49.             // just ensure that the window is active
    50.             if (rootFrame == null && !AppCallbacks.IsInitialized())
    51.             {
    52.                 rootFrame = new Frame();
    53.                 Window.Current.Content = rootFrame;
    54. #if !UNITY_HOLOGRAPHIC
    55.                 Window.Current.Activate();
    56. #endif
    57.                 rootFrame.Navigate(typeof(StartPage));
    58.             }
    59.  
    60.             // Setup scripting bridge
    61.             var bridge = new WinRTBridge.WinRTBridge();
    62.  
    63.             AppCallbacks.SetBridge(bridge);
    64.             AppCallbacks.InitializeD3DXAML();
    65.             AppCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow);
    66.             Window.Current.Activate();
    67.             // I have exception after this point
    68.         }
    69.  
    70.         public static void ReInitializeUnity()
    71.         {
    72.             CubeBehaviourScript.UnloadApplication();
    73.             // This we need some delay, actualy I do "UnloadApplication" on button click and then ReInitializeUnity() on click of other button
    74.             ((App) Current).InitializeUnity(string.Empty);
    75.         }
    76.  
    77.         private void SetupOrientation()
    78.         {
    79.             UnityGenerated.SetupDisplay();
    80.         }
    81.     }
    82. }
    If it will usefull would be great.
    Anyway, Thanks!
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Don't recreate WinRTBridge - that will cause issues. I'll post a code sample we use to test this later.

    By the way - you can enable "Mixed mode debugging" in project properties to be able to see details of the exception.
     
    semih-guresci likes this.
  7. semih-guresci

    semih-guresci

    Joined:
    Sep 3, 2013
    Posts:
    2
    I have the same problem, after Application.Unload() unity could not start properly. I removed unload and add
    Code (CSharp):
    1. NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required;
    Then, I managed to display unity and navigate between pages. but this way unity stays in the memory.

    Can you share the simple code to initialize unity multiple times in an uwp application?

    Thanks!
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Yeah. Here's code from our automated test:

    Code (csharp):
    1. void App::RunUnityPlayer()
    2. {
    3.     auto appArgs = ref new Platform::Array<String^>(1);
    4.     appArgs[0] = ref new Platform::String(L"-appendlog");
    5.     auto appCallbacks = ref new AppCallbacks(appArgs);
    6.     appCallbacks->SetCoreApplicationViewEvents(m_ApplicationView);
    7.     appCallbacks->SetCoreWindowEvents(m_CoreWindow);
    8.     appCallbacks->InitializeD3DWindow();
    9.     appCallbacks->Run();
    10. }
    11.  
    12. void App::Run()
    13. {
    14.     for (int i = 0; i < 10; i++)
    15.     {
    16.         RunUnityPlayer();
    17.  
    18.         // Pump UI events for 3 secs so all of our threads waiting on UI thread get a chance to exit
    19.         LARGE_INTEGER frequency, start, current;
    20.         QueryPerformanceFrequency(&frequency);
    21.         QueryPerformanceCounter(&start);
    22.         current = start;
    23.  
    24.         do
    25.         {
    26.             Windows::UI::Core::CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(Windows::UI::Core::CoreProcessEventsOption::ProcessAllIfPresent);
    27.             QueryPerformanceCounter(&current);
    28.         }
    29.         while (static_cast<double>(current.QuadPart - start.QuadPart) / static_cast<double>(frequency.QuadPart) < 3.0);
    30.  
    31.         CoFreeUnusedLibrariesEx(0, 0);
    32.     }
    33. }
     
  9. paulb39

    paulb39

    Joined:
    Oct 27, 2013
    Posts:
    17
    Hey @Tautvydas-Zilys, I have the exact same requirement but I am having a hard time understanding your solution.

    I am using Unity 2018.4 with a .net back end.

    I had the same problem as semih-guresci - after I do Application.Unload(), when I navigate to the MainPage all I get is a blank page.

    I changed the cache mode to NavigationCacheMode = NavigationCacheMode.Disabled, that tries to re-create the page.

    When you create a UWP project, it sets the appCallBack to appCallbacks = AppCallbacks.Instance. After a Unload(), AppCallbacks.Instance is null which makes it break.

    So I am now trying to re-create appCallBacks like you said:

    Code (CSharp):
    1.             if (appCallbacks == null)
    2.             {
    3.                 appCallbacks = new AppCallbacks();
    4.             }
    It blows up on appCallbacks.InitializeD3DXAML(); I have the same problem as unity_0PfXqw83o46aIg, visual studio doesn't give me any debug info other than

    Exception thrown at 0x00007FFB628576D9 (UnityPlayer.dll) in UnityChessGame.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

    I have mixed mode debugging on in my project settings.

    Any idea what I am doing wrong?
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    You can only have one AppCallbacks object at a time. Furthermore, you need to more sure that AppCallbacks is destructured/garbage collected before creating a new one.

    Can you share your full code? Is unloading a hard requirement when navigating to another page? Perhaps you can just pause Unity instead?
     
  11. paulb39

    paulb39

    Joined:
    Oct 27, 2013
    Posts:
    17
    Hey, the unloading for me is a hard requirement.

    I made a sample project for you that shows the problem.

    First page is DashPage - that has a button that loads Unity via MainPage. Unity has a Back Button, the code called is in ButtonHandlers - it calls Application.Unload(), then the code in UnityToXAMLEventCallback to navigate back to DashPage. When you go to unity again is where it breaks. I put the AppCallbacks and bridge object
    in a constants class to only keep 1 instance, but it made no difference.

    https://www.dropbox.com/s/lvd4rndlf2amzb8/test-18-uwp.zip?dl=0
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Bridge should only be instantiated once, so putting it into Constants is OK.

    You need to construct new AppCallbacks class every time you initialize Unity. You cannot reuse the one you unloaded.

    Here an example in C# app running the player 10 times (previous one was in C++):

    Code (csharp):
    1. using System;
    2. using UnityPlayer;
    3. using Windows.ApplicationModel;
    4. using Windows.ApplicationModel.Activation;
    5. using Windows.ApplicationModel.Core;
    6. using Windows.UI.Core;
    7. using Windows.System;
    8. using Windows.UI.ViewManagement;
    9.  
    10. namespace UnloadApp
    11. {
    12.     class App : IFrameworkView, IFrameworkViewSource
    13.     {
    14.         private WinRTBridge.WinRTBridge m_Bridge;
    15.         private CoreApplicationView m_ApplicationView;
    16.         private CoreWindow m_Window;
    17.  
    18.         public App()
    19.         {
    20.             SetupOrientation();
    21.  
    22.             m_Bridge = new WinRTBridge.WinRTBridge();
    23.         }
    24.  
    25.         public virtual void Initialize(CoreApplicationView applicationView)
    26.         {
    27.             m_ApplicationView = applicationView;
    28.             applicationView.Activated += ApplicationView_Activated;
    29.         }
    30.  
    31.         private void ApplicationView_Activated(CoreApplicationView sender, IActivatedEventArgs args)
    32.         {
    33.             CoreWindow.GetForCurrentThread().Activate();
    34.         }
    35.  
    36.         public void SetWindow(CoreWindow coreWindow)
    37.         {
    38.             m_Window = coreWindow;
    39.         }
    40.  
    41.         public void Load(string entryPoint)
    42.         {
    43.         }
    44.  
    45.         public void Run()
    46.         {
    47.             // Run 5 times
    48.             for (int i = 0; i < 10; i++)
    49.             {
    50.                 var appCallbacks = new AppCallbacks(); // NOTE: always construct new AppCallbacks!
    51.                 appCallbacks.SetBridge(m_Bridge);
    52.                 appCallbacks.SetCoreApplicationViewEvents(m_ApplicationView);
    53.                 appCallbacks.SetCoreWindowEvents(m_Window);
    54.                 appCallbacks.InitializeD3DWindow();
    55.                 appCallbacks.Run();
    56.             }
    57.         }
    58.  
    59.         public void Uninitialize()
    60.         {
    61.         }
    62.  
    63.         [MTAThread]
    64.         static void Main(string[] args)
    65.         {
    66.             var app = new App();
    67.             CoreApplication.Run(app);
    68.         }
    69.  
    70.         public IFrameworkView CreateView()
    71.         {
    72.             return this;
    73.         }
    74.  
    75.         private void SetupOrientation()
    76.         {
    77.             Unity.UnityGenerated.SetupDisplay();
    78.         }
    79.     }
    80. }
     
  13. paulb39

    paulb39

    Joined:
    Oct 27, 2013
    Posts:
    17
    I can't figure out what I am doing wrong. I updated the sample to not create AppCallbacks in App.xaml and to only create a AppCallbacks object in the main page. I am creating a new class every time with:

    Code (CSharp):
    1. var m_AppCallbacks = new AppCallbacks();
    Same issue, it works the first time, but when you go back and try to re-create it fails.

    https://gist.github.com/paulb39/5f5375e75333274fc165ffc6b0bd8d5d
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Can you define "fails"? What happens? You crash? Do you have a callstack?
     
  15. paulb39

    paulb39

    Joined:
    Oct 27, 2013
    Posts:
    17
    Correct, it crashes. I have mix mode debugging on but visual studio doesn't give me anything helpful. Here's the output from when I hit the go to unity button a second time after navigating back, it doesn't show anything useful:

    Code (CSharp):
    1. [0.021748 / 0.025173] - Initializing Unity runtime
    2. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFBD2C804B0: (caller: 00007FFBD2C801F5) ReturnHr(5) tid(2884) 80070490 Element not found.
    3. [0.000250 / 0.025794] - AppCallbacks::SetCoreWindowEvents
    4. [0.000005 / 0.025896] - AppCallbacks::InitializeD3DXAML
    5. [0.055917 / 0.055917] - OnSwapChainPanelSizeChanged event Old Size (0.00, 0.00) New Size (1010.00, 508.67), m_Initialized=False.
    6. Module information:
    7. Built with Compiler Ver '191326128'
    8. Built from '2018.4/staging' branch
    9. Version is '2018.4.17f1 (b830f56f42f0)'
    10. Debug build
    11. Application type 'XAML'
    12.  
    13. OS 'Windows 10 (10.0.18362) 64bit'
    14.  
    15. PlayerConnection initialized from C:/projects/Unity/Research/UWP/18-examl-uwp/test-18-uwp/UWP/test-18-uwp/bin/x64/Debug/AppX/Data (debug = 0)
    16.  
    17. 'test-18-uwp.exe' (Win32): Loaded 'C:\Windows\System32\wshbth.dll'. Cannot find or open the PDB file.
    18. 'test-18-uwp.exe' (Win32): Loaded 'C:\Windows\System32\FWPUCLNT.DLL'. Cannot find or open the PDB file.
    19. Connecting directly to Ip=192.168.1.102, port=34999 ...
    20.  
    21. Socket: connect failed, error: Operation has failed with error 0x274d: No connection could be made because the target machine actively refused it.
    22. (0)
    23. (Filename: C:\buildslave\unity\build\Runtime/Network/Sockets.cpp Line: 415)
    24.  
    25.  
    26. connect failed
    27. (Filename: C:\buildslave\unity\build\Runtime/Network/Sockets.cpp Line: 161)
    28.  
    29.  
    30. Connect failed for direct socket. Ip=192.168.1.102, port=34999
    31. (Filename: C:\buildslave\unity\build\Runtime/Network/PlayerCommunicator/PlayerConnection.cpp Line: 475)
    32.  
    33.  
    34. Connecting directly to Ip=192.168.1.102, port=34999 ...
    35.  
    36. [3.302162 / 3.358078] - OnWindowActivated event - Deactivated.
    37. Socket: connect failed, error: Operation has failed with error 0x274d: No connection could be made because the target machine actively refused it.
    38. (0)
    39. (Filename: C:\buildslave\unity\build\Runtime/Network/Sockets.cpp Line: 415)
    40.  
    41.  
    42. connect failed
    43. (Filename: C:\buildslave\unity\build\Runtime/Network/Sockets.cpp Line: 161)
    44.  
    45.  
    46. Connect failed for direct socket. Ip=192.168.1.102, port=34999
    47. (Filename: C:\buildslave\unity\build\Runtime/Network/PlayerCommunicator/PlayerConnection.cpp Line: 475)
    48.  
    49.  
    50. Connecting directly to Ip=192.168.1.102, port=34999 ...
    51.  
    52. Socket: connect failed, error: Operation has failed with error 0x274d: No connection could be made because the target machine actively refused it.
    53. (0)
    54. (Filename: C:\buildslave\unity\build\Runtime/Network/Sockets.cpp Line: 415)
    55.  
    56.  
    57. connect failed
    58. (Filename: C:\buildslave\unity\build\Runtime/Network/Sockets.cpp Line: 161)
    59.  
    60.  
    61. Connect failed for direct socket. Ip=192.168.1.102, port=34999
    62. (Filename: C:\buildslave\unity\build\Runtime/Network/PlayerCommunicator/PlayerConnection.cpp Line: 475)
    63.  
    64.  
    65. Connecting to host time out, player connection will be disabled.
    66. (Filename: C:\buildslave\unity\build\Runtime/Network/PlayerCommunicator/PlayerConnection.cpp Line: 70)
    67.  
    68.  
    69. [6.528948 / 6.593972] - Initialize
    70. [XR] Discovering subsystems at path C:/projects/Unity/Research/UWP/18-examl-uwp/test-18-uwp/UWP/test-18-uwp/bin/x64/Debug/AppX/Data/UnitySubsystems
    71.  
    72. GfxDevice: creating device client; threaded=1
    73.  
    74. 'test-18-uwp.exe' (Win32): Loaded 'C:\Windows\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_a3efb8aa9e9e249a\NvCamera\NvCameraWhitelisting64.dll'. Cannot find or open the PDB file.
    75. 'test-18-uwp.exe' (Win32): Unloaded 'C:\Windows\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_a3efb8aa9e9e249a\NvCamera\NvCameraWhitelisting64.dll'
    76. Direct3D:
    77.  
    78.     Version:  Direct3D 11.0 [level 11.1]
    79.  
    80.     Renderer: NVIDIA GeForce GTX 1080 (ID=0x1b80)
    81.  
    82.     Vendor:  
    83.  
    84.     VRAM:     8079 MB
    85.  
    86. Initialize engine version: 2018.4.17f1 (b830f56f42f0)
    87.  
    88. [AudioManager] InitNormal(tryDeviceDefaults = false, preferredOutputType = FMOD_OUTPUTTYPE_AUTODETECT) attempt with hardAudioDisable: false
    89.  
    90. [AudioManager] Setting output to FMOD_OUTPUTTYPE_AUTODETECT
    91.  
    92. [AudioManager] InitNormal succeeded with output "FMOD_OUTPUTTYPE_WASAPI". Driver name is "Speakerss (Realtek(R) Audio)". Speaker mode is "FMOD_SPEAKERMODE_STEREO"
    93.  
    94. The thread 0x5050 has exited with code 0 (0x0).
    95. The thread 0x3cdc has exited with code 0 (0x0).
    96. [3.662454 / 7.020533] - MonoManager::ctor
    97. [0.008635 / 7.029168] - MonoManager::FillCommonScriptingClasses begin...
    98. [0.002678 / 7.031846] - MonoManager::FillCommonScriptingClasses end...
    99. [0.000116 / 7.064857] - AppCallbacks::SetupInputEvents
    100. onecoreuap\drivers\mobilepc\sensors\convergence\common\pnpmanager\pnpmanager.cpp(591)\Windows.Devices.Sensors.dll!00007FFB7EEBDFD5: (caller: 00007FFB7EEAA56F) Exception(6) tid(2884) 80070490 Element not found.
    101. Exception thrown at 0x00007FFBE509A839 in test-18-uwp.exe: Microsoft C++ exception: wil::ResultException at memory location 0x000000E4261FCF70.
    102. Exception thrown at 0x00007FFBE509A839 in test-18-uwp.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    103. The thread 0x5664 has exited with code 0 (0x0).
    104. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\simpleorientation.cpp(127)\Windows.Devices.Sensors.dll!00007FFB7EEB5B76: (caller: 00007FFB7EEABB9B) Exception(7) tid(2884) 80070490 Element not found.
    105. Exception thrown at 0x00007FFBE509A839 in test-18-uwp.exe: Microsoft C++ exception: wil::ResultException at memory location 0x000000E4261FD140.
    106. Exception thrown at 0x00007FFBE509A839 in test-18-uwp.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    107. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensorserver.cpp(68)\Windows.Devices.Sensors.dll!00007FFB7EEA744B: (caller: 00007FFB7EEA3763) ReturnHr(4) tid(2884) 80070490 Element not found.
    108. onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\lib\simpleorientationsensor.cpp(160)\Windows.Devices.Sensors.dll!00007FFB7EE9182C: (caller: 00007FFB7EE8EBC3) ReturnHr(5) tid(2884) 80070490 Element not found.
    109. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFBD2C7E65E: (caller: 00007FFBD2C7DBF2) ReturnHr(6) tid(2884) 80070490 Element not found.
    110. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFBD2C7E65E: (caller: 00007FFBD2C7D7EC) ReturnHr(7) tid(2884) 80070490 Element not found.
    111. onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FFBD2C7E65E: (caller: 00007FFBD2C7DBF2) ReturnHr(8) tid(2884) 80070490 Element not found.
    112. [0.115068 / 7.180047] - AppCallbacks::SetupOrientationSensorEvents
    113. [0.127552 / 7.187736] - AppCallbacks::Load
    114. [0.156057 / 7.187903] - Starting first scene loading
    115. The following GlobalManagers were stripped from the build (Either because they're not used or not supported on this platform):
    116.  ClusterInputManager
    117.  
    118. Exception thrown at 0x00007FFB6285771D (UnityPlayer.dll) in test-18-uwp.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
    upload_2020-3-24_23-2-49.png
     
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
  17. paulb39

    paulb39

    Joined:
    Oct 27, 2013
    Posts:
    17
    Unfortunately still doesn't show anything useful:

    upload_2020-3-25_9-11-18.png

    upload_2020-3-25_9-14-44.png
     
  18. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    That's plenty useful. It shows that you're crashing when drawing the splashscreen. Can you try disabling it in player settings?

    Also, this is likely a bug in Unity. Can you report a bug?
     
  19. paulb39

    paulb39

    Joined:
    Oct 27, 2013
    Posts:
    17
    Unfortunately I can't test that because you need Unity Pro to remove the splash screen.

    I'll create a ticket - I am trying to first see if this happens using c++ as well, but I can't figure out the syntax to create the delegate connection to the back button.

    How in the world do I convert this lambda to c++?

    Code (CSharp):
    1.             AppCallbacks.Instance.InvokeOnAppThread(() =>
    2.             {
    3.                 SetEventCallback(UnityToXAMLEventCallback);
    4.  
    5.             }, false);

    If this is a bug, can you think of a workaround to fix? I tried setting the cache mode back to required, and putting the AppCallbacks logic in OnNavigatedTo instead, but it still crashes on draw splash screen, I don't know what else to try. I am 90% done with my project, but it is dead in the water if I can't find a fix for this.
     
  20. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    C++:

    Code (csharp):
    1. AppCallbacks::Instance->InvokeOnAppThread([=]()
    2. {
    3.     SetEventCallback(UnityToXAMLEventCallback);
    4. }, false);
    The only workaround I can thing of is to not call Application.Unload when you switch to a different page, and instead call AppCallbacks.UnityPause instead. Then when coming back, reuse the same AppCallbacks object and just use AppCallbacks.UnityPause again.
     
  21. paulb39

    paulb39

    Joined:
    Oct 27, 2013
    Posts:
    17
    Thanks, apologies, I really want to submit the ticket with a c++ example since I know they are going to tell me c# is deprecated if I submit the c# example. I am now stuck on converting this function to c++:


    Code (CSharp):
    1.         public static void SetEventCallback(UnityEvent e)
    2.         {
    3.             // Get the object the communication class is attached to.
    4.             UnityEngine.GameObject gameObject = UnityEngine.GameObject.Find("Main Camera");
    5.             if (gameObject != null)
    6.             {
    7.                 // Create an event object on that class so we can send events.
    8.                 var bh = gameObject.GetComponent<ButtonHandlers>();
    9.                 if (bh != null)
    10.                 {
    11.                     bh.unityButtonEvent = new ButtonHandlers.OnEvent(e);
    12.                 }
    13.             }
    14.             else
    15.             {
    16.                 throw new Exception("Camera not found, have you exported the correct scene?");
    17.             }
    18.         }
    It doesn't understand UnityEngine, I can't find anything in the docs, is there no UnityEngine namespace in c++?

    It also doesn't understand ButtonHandlers, which is the script in the Unity project, is there no way for c++ to talk back to the Unity project?
     
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    You don't have to do all this. Take my example script and run it with D3D project with splash screen enabled.
     
  23. paulb39

    paulb39

    Joined:
    Oct 27, 2013
    Posts:
    17
    So I submitted a report via the editor a couple of weeks ago and forgot about it. Went to check the status - I don't see anywhere in the editor, or on the site to see tickets I have submitted. I also don't see any emails from Unity. How can I find the ticket number so I can check the status?
     
  24. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    What's the ticket number?
     
  25. paulb39

    paulb39

    Joined:
    Oct 27, 2013
    Posts:
    17
    That was my question - I never got a confirmation email, and I don't see anywhere in the editor or site where I can see a list of tickets I submitted, so I don't know how to find the ticket number.
     
  26. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    Can you PM me the email you used to submit it? I can follow up.
     
  27. paulb39

    paulb39

    Joined:
    Oct 27, 2013
    Posts:
    17