Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Build for UWP C# with IL2CPP

Discussion in 'Windows' started by madhur, Apr 17, 2019.

  1. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Hi,

    I have a Unity project which we built for UWP using .Net as scripting backend. When I try to run it in Unity 2019, noticed that .Net is not there anymore and we have to build it using IL2CPP.
    When I try to build it with IL2CPP, it is giving an error '
    error CS0246: The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)'

    This is the code part related to that
    Code (CSharp):
    1.  
    2. using Windows.Storage;
    3. ....
    4. StorageFolder storageFolder = ApplicationData.Current.LocalFolder;

    So with the .net option being removed, is it possible to build a Unity project which has c# scripts as UWP to be used in a C# UWP project.
    If possible, can you please tell me how to solve reference issues like this?

    Thanks
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Where are you putting this code? Is it in your Unity Project? You need to wrap usages of Windows namespace in #if ENABLE_WINMD_SUPPORT/#endif.
     
  3. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Thanks @Tautvydas-Zilys , it was in the Unity project and after adding the if condition got it working.

    Now I need to integrate that UWP project built with IL2CPP with my C# UWP project.
    I have been following this thread https://forum.unity.com/threads/solved-xamlunityconnection-in-il2cpp-xaml-c-il2cpp.495345/
    But still not clear what I have to do.
    I have also looked at this project https://github.com/TautvydasZilys/unity-uwp-il2cpp-with-csharp-project-example and there I am seeing a c# project file and a c++ project file. I am not sure how I can combine both these projects.
    Also when I tried to run the UWP app created from this example built using Unity 2019 I am getting these errors,

    Error Payload file 'E:\Samples\unity-uwp-il2cpp\bin\build\bin\x86\Debug\SymbolMap' does not exist.
    Error Payload file 'E:\Samples\unity-uwp-il2cpp\bin\build\bin\x86\Debug\GameAssembly.dll' does not

    Can you please explain how you created this example project. I need to know how to integrate an existing C# UWP project with a Unity IL2CPP built UWP project. Any help will be really appreciated.

    Will that work in Unity 2019 and Visual studio 2019?
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    The C++ project file in that github repo isn't actually used. It's just produced by Unity every time you build so I didn't bother deleting it. It's all in the C# project.

    SymbolMap file is no longer used in Unity 2019.1. You should modify the C# project file to not include it. However, GameAssembly.dll should be built from Il2CppOutputProject - does the build even get triggered? Perhaps it fails for some reason?

    I created the project by just making a new UWP project from Visual Studio, and then I added references to Unity pieces manually.
     
  5. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    @Tautvydas-Zilys Thanks for your help. I managed to integrate a C# UWP app with a UWP project built with IL2CPP and then I added the Windows runtime component as you have explained to do the communication and got that also working. But one thing I noticed is when I run the app in Visual studio, it prints only the logs I have added in Visual studio project, but the ones I have added in Unity Script.cs file (IL2CPPBridge class) doesn't get printed. But the logic I have added inside the MyFunction3 and MyFunction4 get executed, only issue is logs not printing.
    But when I added the same code your 'unity-uwp-il2cpp-with-csharp-project-example' then it prints all the logs from Unity as well. I have used the same settings when building both projects.

    Also the AddActivatedEventArgs doesn't seem to print those logs in my project.
    If you have any idea what I have missed please let me know.

    Thank you.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    The output from Unity side will only show up in VS output window if you use mixed mode debugger. That setting can be found in project properties, debug tab.
     
  7. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
  8. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    For anyone trying to integrate a C# UWP app with a Unity UWP app as a C# project and do the communication there, these are the steps I followed with the help of Tautvydas-Zilys in https://forum.unity.com/threads/solved-xamlunityconnection-in-il2cpp-xaml-c-il2cpp.495345/
    • Create a blank Universal App in C#. Name TestApp1

    • Create a New Unity project. Name TestApp1
      • Open the sample scene

      • Go to build settings add open scene

      • and switch to Universal Windows Platform

      • Select Build type as XAML project
      • Select Copy references option (then it’ll copy the unity player references to the sln)

      • Then Build
    • Update the .sln file of the C# UWP project by looking at the .sln file of the Unity built project. E.g add these parts
    Code (CSharp):
    1. ProjectSection(ProjectDependencies) = postProject
    2.  
    3.         {EA17D85E-DA6F-49EA-A879-8F48265B121D} = {EA17D85E-DA6F-49EA-A879-8F48265B121D}
    4.  
    5.     EndProjectSection
    6.  
    7. EndProject
    8.  
    9. Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Unity Data", "TestApp1\Unity Data.vcxitems", "{C102B663-472B-4E4D-B82E-F8B2FAD767AA}"
    10.  
    11. EndProject
    12.  
    13. Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Il2CppOutputProject", "Il2CppOutputProject\Il2CppOutputProject.vcxproj", "{EA17D85E-DA6F-49EA-A879-8F48265B121D}"
    14.  
    15. EndProject

    • Copy the Il2CppOutputProject folder and the UnityCommon file from the Unity built project to the C# UWP app folder and also copy the Data and Managed folders in TestApp1 folder from the Unity built project to C# project - TestApp1 folder . Also copy the Resource, StoreManifest, Unity Data, Unity Data.vcxitems, UnityGenerated files also there.

    • Add these lines to TestApp1 C# project file
    <Import Project="..\UnityCommon.props" />

    <ItemGroup>
    <Reference Include="UnityPlayer">
    <SpecificVersion>False</SpecificVersion> <HintPath>$(UnityWSAPlayerDir)Players\UAP\il2cpp\$(PlatformTarget)\$(Configuration)\UnityPlayer.winmd</HintPath>
    </Reference>
    </ItemGroup>
    <ItemGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64' OR '$(Configuration)|$(Platform)'=='Release|x64'">
    <Content Include="$(UnityWSAPlayerDir)Players\UAP\il2cpp\$(PlatformTarget)\$(Configuration)\WinPixEventRuntime_UAP.dll" />
    </ItemGroup>

    <ItemGroup>
    <Content Include="$(SolutionDir)build\bin\$(Platform)\$(Configuration)\GameAssembly.dll" />
    <Content Include="$(SolutionDir)build\bin\$(Platform)\$(Configuration)\GameAssembly.pdb" />
    </ItemGroup>


    <Content Include="Resource.res">
    </Content>
    <Content Include="StoreManifest.xml">
    </Content>
    <Content Include="Data\**">
    <ExcludeFromResourceIndex>true</ExcludeFromResourceIndex>
    </Content>

    • Now open the .sln in the C# UWP project.

    • Make sure the TestApp1 (Universal Windows) app is set as the Start up project. If the other project is set as Start up (Which is shown in bold letters) so change it by right clicking the project and setting as Start up project in Solution explorer

    • In VS select Debug - x64
    Then to add the C# to Unity communication part
    • Add the content of the App.xaml.cs and MainPage.xaml and cs file from the given example to the existing files (Make sure to change the namespace in all the places)

    • Comment the OnAppActivated method and the line calling it, in the App.xaml.cs in that example

    • In the same solution, go to new project -> C++ -> Windows Universal -> Windows Run time component. Select the path as \TestApp1 folder and select Add to solution and name it as IL2CPPToDotNetBridge

    • Copy the content to the Class1.h file and comment the Class1 implementation code in the Class1.cpp file

    • From the TestApp1 Project add a Reference to the IL2CPPToDotNetBridge component (Add Reference -> Projects -> you will this project)

    • In the MainPage.xaml.cs add DotNetBridge class sample code given and call it from MainPage()

    • Clean and build the solution.

    • Copy the IL2CPPToDotNetBridge.dll and IL2CPPToDotNetBridge.winmd files that get generated in x64\Debug\IL2CPPToDotNetBridge and paste in the Unity project’s Assets folder

    • Create Script.cs file in Unity projects Assets/Scripts folder and add the given content there.

    • Then add that script to the Main camera

    • Build it and copy the same files/folders as earlier

    • Go to VS ->TestApp1 -> Properties -> Debug -> Debugger Type -> Mixed

    • Clean and build and run the solution.

    • You should see the Unity logs and the C# UWP app logs
     
    Last edited: Aug 30, 2019
  9. yakumoklesk

    yakumoklesk

    Joined:
    Dec 12, 2013
    Posts:
    5
    That is really cumbersome. I wonder if there could be a way of automating all of this, like for example giving some extra information to Unity when building projects.
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    I'll see what I can come up with.
     
    yakumoklesk likes this.
  11. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    and? because this is a nightmare :/
    When it wasn't il2cpp it was so much easier, now it's a pain in the butt to try to communicate accross
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    You can do this in OnPostprocessBuild callback. Or, you can do this manually once and then check-in the project into your source control.

    We don't have anything in the works for this scenario, unfortunately.

    I understand it's cumbersome to do this but to be fair, you'd have to do exact same things for all other platforms Unity supports and while it was more convenient on .NET scripting backend, it was a mere side effect of the fact that Unity used the same .NET runtime as the "rest of the app". It wasn't an explicit design goal.

    If you explain what you're trying to do, perhaps I can come up with a less painful way to do it.
     
  13. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I'm trying to use the Microsoft Advertising sdk for xaml. I don't think I can call that from inside unity (or is there a way to include the package to the solution?). So I have to be able to call methods from unity into the visual studio xaml project so display/retrieve ad status.
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    You can call into it from Unity. I threw together a project that does just that. Just don't forget to add a reference to the ads SDK in generated Visual Studio project (otherwise you'll get class not registered exception).

    I used this page as guidance in order to be able to do it: https://marketplace.visualstudio.com/items?itemName=AdMediator.MicrosoftAdvertisingSDK
     

    Attached Files:

  15. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    nice, i didn't know you could add the package into the unity project.
     
  16. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    You can add anything that's reference-able from a VS project.
     
  17. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    well, when i try to build i get this error:
    error CS0234: The type or namespace name 'Advertising' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

    I open the Setup.cs file and try to add a reference, but visual studio does not allow me to add the Advertising SDK (or any reference in fact). How did you manage it to include it?
     
  18. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Ok, I figured it out. I add to attach the Microsoft.Store.winmd file you created. Now the question is... how did you create that file?
     
  19. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    I took it from the nuget package and placed it in the Unity project.
     
  20. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I'm trying to do:
    using Microsoft.Services.Store.Engagement;

    any idea how to be able to generate the winmd for that? It fails to compile saying it doesn't find that namespace (when I try to build for UWP)
     
  21. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
  22. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    so basically the way it works is to download the nuget, hope there is a .winmd file and put it in?
     
  23. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    There will be either .winmd and .dll files in that NuGET package. Visual Studio needs to reference those files to compile C# code in a UWP application - it's not magic. It just extracts the NuGET package automatically for you, which Unity does not do.
     
  24. MuhammadHaseeb56

    MuhammadHaseeb56

    Joined:
    Mar 12, 2019
    Posts:
    13
    i cant understand it please me to hw i can apply ads in il2cpp build?
     
  25. chadfranklin47

    chadfranklin47

    Joined:
    Aug 11, 2015
    Posts:
    221
    @Tautvydas-Zilys Hello, I am attempting to embed a Unity view inside UWP Xaml C# project and I believe I am almost there following your guide and I thank everyone for helping me get to this point. I followed the instructions, and I am getting the Unity logs as well as the C# UWP app logs, and the Unity view comes up successfully, but I am also getting many of these logs every second:

    Exception thrown at 0x00007FF95F9AA859 in [Project Name].exe: Microsoft C++ exception: _com_error at memory location 0x000000A83AB011A8.

    Have any of you encountered this before or know what could be causing this if I did a step wrong? Thanks again.
     
    Last edited: Apr 11, 2020
  26. chadfranklin47

    chadfranklin47

    Joined:
    Aug 11, 2015
    Posts:
    221
    Maybe this can help show what's happening:

    (note I commented out the bridge bootstrapper lines trying to narrow the problem down so those logs are not here)

    Update: Okay, I believe this is a Unity problem, not a problem with this method as I still get these errors if I simply build and run the Unity built UWP solution from the c++ project. Still not sure what to do from here though.

    Update 2: Okay, I found this, and "it's not a bug": https://issuetracker.unity3d.com/issues/lwrp-project-spawns-multiple-exception-in-uwp-build



    'Music Visualizer Test.exe' (Win32): Loaded 'C:\Windows\System32\biwinrt.dll'.
    onecoreuap\xbox\devices\api\winrt\pnpapiwrapper.cpp(385)\Windows.Gaming.Input.dll!00007FF955496CA4: (caller: 00007FF95549A640) ReturnHr(1) tid(8a2c) 8685C003 onecoreuap\drivers\mobilepc\sensors\convergence\common\pnpmanager\pnpmanager.cpp(591)\Windows.Devices.Sensors.dll!00007FF8BB7BDFD5: (caller: 00007FF8BB7AA56F) Exception(1) tid(32f8) 80070490 Element not found.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0000006BED47CD80.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    The thread 0x29b8 has exited with code 0 (0x0).
    onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\simpleorientation.cpp(127)\Windows.Devices.Sensors.dll!00007FF8BB7B5B76: (caller: 00007FF8BB7ABB9B) Exception(2) tid(32f8) 80070490 Element not found.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: wil::ResultException at memory location 0x0000006BED47CF50.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
    onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\internal\sensorserver.cpp(68)\Windows.Devices.Sensors.dll!00007FF8BB7A744B: (caller: 00007FF8BB7A3763) ReturnHr(1) tid(32f8) 80070490 Element not found.
    onecoreuap\drivers\mobilepc\sensors\convergence\api\winrt\public\lib\simpleorientationsensor.cpp(160)\Windows.Devices.Sensors.dll!00007FF8BB79182C: (caller: 00007FF8BB78EBC3) ReturnHr(2) tid(32f8) 80070490 Element not found.
    onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FF952D3E65E: (caller: 00007FF952D3DBF2) ReturnHr(3) tid(32f8) 80070490 Element not found.
    onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FF952D3E65E: (caller: 00007FF952D3D7EC) ReturnHr(4) tid(32f8) 80070490 Element not found.
    onecoreuap\windows\wgi\winrt\display\displaycommon.cpp(411)\Windows.Graphics.dll!00007FF952D3E65E: (caller: 00007FF952D3DBF2) ReturnHr(5) tid(32f8) 80070490 Element not found.
    [0.142961 / 4.518562] - AppCallbacks::SetupOrientationSensorEvents
    'Music Visualizer Test.exe' (Win32): Loaded 'C:\Windows\System32\windows.applicationmodel.datatransfer.dll'.
    'Music Visualizer Test.exe' (Win32): Loaded 'C:\Windows\System32\coml2.dll'.
    'Music Visualizer Test.exe' (Win32): Loaded 'C:\Windows\System32\edputil.dll'.
    [0.185990 / 4.547715] - AppCallbacks::Load
    [2.272083 / 4.547944] - Starting first scene loading
    The following GlobalManagers were stripped from the build (Either because they're not used or not supported on this platform):
    ClusterInputManager
    UnityConnectSettings
    Begin showing splash screen.
    [1.267255 / 5.815199] - OnWindowActivated event - Deactivated.
    The thread 0xad24 has exited with code 0 (0x0).
    The thread 0x9c9c has exited with code 0 (0x0).
    [0.306519 / 6.121719] - OnVisibilityChanged event - Hidden.
    [0.430904 / 6.552623] - Finishing first scene loading
    UnloadTime: 2.426200 ms
    [0.033215 / 6.585838] - First level loaded
    [0.000299 / 6.586137] - PerformUpdateAndRender started
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: _com_error at memory location 0x0000006BF14E0E58.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: _com_error at memory location 0x0000006BF14E0E58.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: _com_error at memory location 0x0000006BF14E0E58.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: _com_error at memory location 0x0000006BF14E0E58.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: _com_error at memory location 0x0000006BF14E0E58.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: _com_error at memory location 0x0000006BF14E0E58.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: _com_error at memory location 0x0000006BF14E0E58.
    End showing splash screen.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: _com_error at memory location 0x0000006BF14E0E58.
    Exception thrown at 0x00007FF95F9AA859 in Music Visualizer Test.exe: Microsoft C++ exception: _com_error at memory location 0x0000006BF14E0E58.
     
    Last edited: Apr 12, 2020
  27. mfv_unity

    mfv_unity

    Joined:
    Mar 1, 2021
    Posts:
    4
    Hi.

    I followed these instructions (minus the communication part) and they worked fine when using Unity 2018.4.36f1 and a Windows platform target of 10.0.10240. However, following the same steps did not work when using Unity 2020.3.25f1 and Windows platform target of 10.0.19041 with 10.0.17763 as minimum. I get a "Failed to load Game Assembly" message. Is there anything that needs to be done differently in the newer versions of Unity and Windows SDK? Is it still possible to have this scenario of a C# UWP application with an embedded Unity window?
     
  28. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    "Failed to load Game Assembly" generally means that GameAssembly.dll was not included in the project and thus wasn't copied to output directory. I'd double check the project file.
     
  29. mfv_unity

    mfv_unity

    Joined:
    Mar 1, 2021
    Posts:
    4
    Thanks for the quick response.

    Apart from GUID, name and platform version, both project files are identical. Looking into the build folder, I see GameAssembly.dll in the same place as in the project that works.
     
  30. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    After you build the game, if you go to a directory where the .exe is located (you can do that by finding it in task manager processes tab, right clicking and pressing "Open File Location"), is GameAssembly.dll there?
     
  31. mfv_unity

    mfv_unity

    Joined:
    Mar 1, 2021
    Posts:
    4
    The .exe was in the bin\x64\Debug folder, inside the project folder. The GameAssembly.dll was in the AppX inside that one. The project that works has the same output.

    In any case, I copied GameAssembly.dll one level up and got the same result.
     
  32. mfv_unity

    mfv_unity

    Joined:
    Mar 1, 2021
    Posts:
    4
    I made another test: I copied the Il2CppOutputProject from the Unity 2020 project into the solution that is working. First, I got an error saying that the baselib.dll files were missing from the Players folder. That was expected, since Unity 2018 does not have that dll. After copying the dll, I cleaned the build, rebuilt and ran the solution, getting the same error I got with the new project: "Failed to load Game Assembly". Reverting this solution to the Unity 2018 Il2CppOutputProject gets it back to working.

    I'm guessing this means that this scenario of a UWP C# app with a Unity panel inside is no longer possible, unless there is some configuration not present on these steps which could make it work.
     
  33. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Looks like the original example project doesn't include baselib.dll, which was added in Unity 2020.3.

    This addition to the .csproj file should make it work again:

    Code (csharp):
    1.     <Content Include="$(UnityWSAPlayerDir)Players\UAP\il2cpp\$(PlatformTarget)\$(Configuration)\baselib.dll" />
    2.     <Content Include="$(UnityWSAPlayerDir)Players\UAP\il2cpp\$(PlatformTarget)\$(Configuration)\baselib.pdb" />
    I updated https://github.com/TautvydasZilys/unity-uwp-il2cpp-with-csharp-project-example to 2020.3.29f1 and moved it to live with our other samples: https://github.com/Unity-Technologi...alWindowsPlatformSamples/CSharpProjectExample. Using it should now work on 2020.3+.
     
    junhossi likes this.
  34. Yishar

    Yishar

    Joined:
    Sep 13, 2017
    Posts:
    11
    Hi,
    Following the instructions and examples in this thread I managed to get unity running inside a UWP application as a XAML component, but I have a question:

    Is there any way of changing the SwapChainPanel on which unity renders after initialization?

    My use case is an application where unity is used to render a small view of a 3D model, and the XAML GUI around shows some metadata and related info to the 3D drawn from a database. I need to be able to navigate between different Pages with different models (which will be changed on Unity side using the communications bridge) and some pages without a Unity view at all. The first loaded view with Unity initializes the engine and shows as expected, but once the original SwapChainPanel is unloaded after navigating to another page, I can't find a way to update Unity's SwapChainPanel that works. appCallbacks.SetSwapChainPanel() seems to do nothing, and calling again InitializeD3DXaml() throws an exception, expected as the engine is already initialized and running on the background.

    Any advice on this? Is it possible?

    Thanks.
     
  35. Yishar

    Yishar

    Joined:
    Sep 13, 2017
    Posts:
    11
    I managed to keep the original SwapChainPanel in a static variable, removing it from the previous instance of the UnityPanel component I made, to the new one on the constructor. This way Unity only has to know a single static SwapChainPanel that is been moved around between pages.

    I don't know if it's the best way to do it though, it feels like a ugly hack.
     
  36. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    I was going to suggest that. The only other way would involve calling Application.Unload from your scripts and then initializing Unity again from scratch. But that's probably not what you want to do.

    I don't think it's a hack. It seems like a reasonable solution to me.
     
    Yishar likes this.
  37. Yishar

    Yishar

    Joined:
    Sep 13, 2017
    Posts:
    11
    Hi again, i'm finding another small problem that i don't know how to fix:
    The unity window in UWP keeps showing the "development build" tag in the lower right corner.
    I'm building the UWP project on release, making sure the IL2CPP project is also in release, added the NDEBUG and _NDEBUG preprocessor tags (can't remember where i found that suggestion), and the referenced UnityPlayer.winmd is the release one.
    What else am I missing to build a release version?
     
  38. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Change the build configuration to "Master" in Visual Studio.
     
  39. Yishar

    Yishar

    Joined:
    Sep 13, 2017
    Posts:
    11
    that was it, I always mix up unity's master and release builds, and UWP Visual Studio projects don't have 'Master' configuration by default, i had to create it.

    Thanks :)