unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.83k stars 711 forks source link

Unity3d support #2390

Open MartinZikmund opened 4 years ago

MartinZikmund commented 4 years ago

What would you like to be added:

Kyryll Vlasiuk asked on the second episode of VS Toolbox :

I have a question to Martin. When working in unity 3d you have the ability to use XAML UI, when targeting UWP APP. In result directx swachain component is used to render unity content to UWP application. Recently unity added the ability to run unity as a library in native applications on ios and android. Do you think, it would be possible to port UWP Unity application with XAML UI to native platform using unity as a library? It would be very cool to be able to use XAML UI with all unity targets not just the UWP.

I originally was thinking about first party Unity3d support, but that would be a major undertaking. This sounds significantly more doable, but might still require some cooperation with Unity3d team.

Why is this needed:

To allow Unity3d users to use Uno Platform.

For which Platform:

breadnone commented 3 years ago

Is this still actively developed?

jeromelaban commented 3 years ago

@breadnone not at this point. What's your scenario for this feature ?

breadnone commented 3 years ago

Never been a fan of Unity's ui solution especially for mobile. Having this as an alternative would be great.

NoTuxNoBux commented 3 years ago

Me and developers from my company have an additional use case that this might help with (unless I misunderstood how Uno works); we use Unity 3D for HoloLens 2 application development. These applications must use the UWP platform. Unity itself supports C#.NET - converting it to C++ using IL2CPP -, but some of these APIs cannot be used in UWP contexts, which means we have to use #ifdefs to provide UWP-compatible code for the HoloLens 2. In turn, this UWP-code can sometimes not run inside the Unity Player without running through the entire build process and building for Desktop or Holographic Windows and UWP, since some of these APIs (I'm looking at you, Windows.Storage) are not available in .NET itself, causing the Unity Player to not recognize them.

The result is a rather cumbersome workflow where you sometimes cannot share code between your own development workstation and the target platform, since you must first build something that works in the Unity Player for straightforward testing and development, and then build a second, UWP-compatible, implementation that you will only be able to test by building or on-device, which also makes testing cumbersome and makes everything more error-prone.

A project such as Uno may be able to help here by bridging the UWP code we need to write for the HoloLens 2 anyway, so it automatically also works inside the Unity Player, reducing the need for multiple implementations. UWP APIs also tend to be stricter than ordinary .NET APIs, so that would reduce the error surface.