Search Unity

SwapChain in UWP - Cannot Unload/Load Unity Runtime again

Discussion in 'Editor & General Support' started by shinobi-djoun, Aug 20, 2019.

  1. shinobi-djoun

    shinobi-djoun

    Joined:
    Nov 26, 2017
    Posts:
    1
    As mentionned in the title, I'm integrating a Unity3D Window inside a XAML Page.

    I'm able to load it, and interact with it between both UI-App threads. But my problem is that: I cannot load another Unity3D Window in the same page, or another page unless if I unload the Unity Runtime using: Application.Unload()

    Which is exactly what i'm doing here:
    Code (CSharp):
    1.  
    2.         public static void UnloadUnity()
    3.         {
    4.             if (AppCallbacks.Instance != null)
    5.                 AppCallbacks.Instance.InvokeOnAppThread(() =>
    6.                 {
    7.                     UnityEngine.Application.Unload();
    8.                 }, false);
    9.         }
    Then when I want to load Unity inside another SwapChain using this:
    Code (CSharp):
    1.  
    2.         public static void LoadV2(SwapChainPanel swapChainPanel)
    3.         {
    4.             // Setup scripting bridge
    5.             //if (_bridge == null)
    6.             _bridge = new WinRTBridge.WinRTBridge();
    7.  
    8.             if (appCallbacks == null)
    9.             {
    10.                 appCallbacks = new AppCallbacks();
    11.             }
    12.  
    13.             appCallbacks.SetAppArguments(_appArguments);
    14.             appCallbacks.SetBridge(_bridge);
    15.  
    16.  
    17.             appCallbacks.SetSwapChainPanel(swapChainPanel);
    18.             appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow);
    19.             if (!appCallbacks.IsInitialized())
    20.                 appCallbacks.InitializeD3DXAML();
    21.  
    22.             Window.Current.Activate();
    23.         }

    I get this error (if I'm loading it in the same page on another SwapChainPanel)
    GetManagerFromContext: pointer to object of manager "PlayerSettings" is NULL (table index 0)

    (Filename ........./unity/build/Runtime/BaseClasses/ManagerContext.cpp Line: 89)
    Or this error (if I navigate to another page with a swapchainpanel)
    upload_2019-8-20_14-3-23.png

    I'm using Unity 2018.4.3f1 along with Visual Studio Enterprise 2017
    Thank you.
     

    Attached Files:

  2. chadfranklin47

    chadfranklin47

    Joined:
    Aug 11, 2015
    Posts:
    229
    Hello, have you solved this?