I'm interested in building a UWP app that, when launched, has a default 2D XAML type view, but can switch to a secondary 3D UrhoSharp view (incidentally, this is to be run on HoloLens). I'm new to UrhoSharp but I'm able to follow some online tutorials that create a 3D UWP UrhoSharp application by creating a new UWP app in Visual Studio, deleting the "App.xaml" and "MainPage.Xaml" classes and then defining a new UrhoSharp entry point by adding the following:
using Urho;
public static class Program
{
[MTAThread]
static void Main() => CoreApplication.Run(new UrhoAppViewSource<MixedRealityApplication>());
}
and:
using Urho;
using Urho.SharpReality;
internal class MixedRealityApplication : StereoApplication
{
public MixedRealityApplication(ApplicationOptions options) : base(options)
{
// Do some initialization.
}
protected override void Start()
{
// Start drawing some 3D stuff
}
}
The above works and I'm able to see my 3D objects. Now I wish to create a UWP application that starts with its default view as a standard 2D XAML window but then be able to switch to a 3D UrhoSharp view when clicking a button. I found a thread on this forum titled "Right Way to Run UrhoSharp As Part of 2D UWP on HoloLens" where the author has done exactly that. However, the code example is very sparse (1 or 2 lines) and I can't get anywhere. I've tried using the (unmodified) "MixedRealityApplication" class in the code above in the way used by the author:
Using Windows.ApplicationMode.Core;
using Urho;
private void Button_Click)object sender, RoutedEventArgs e)
{
CoreApplicationView urho3DView = CoreApplication.CreateNewView(new UrhoAppViewSource<MixedRealityApplication>());
...etc...
}
The above throws the following exception when trying to instantiate "urho3DView": "System.Runtime.InteropServices.COMException: 'A method was called at an unexpected time.'"
I not sure what else to try, and the fact that it seems possible according to the linked post is tantalizing. Does anyone have any idea as to how to go about this? If only the author had shown what "HelloWorldApplication" looks like in his/her code.