I am trying to call from a XAML to a D3D code compiled in Unity for HoloLens device. For that I try to follow instructions of this post.
private void InitializeUnity(string args)
{
if UNITY_WP_8_1 || UNITY_UWP
ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;
endif
if UNITY_WP_8_1
StatusBar.GetForCurrentView().HideAsync();
endif
appCallbacks.SetAppArguments(args);
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null && !appCallbacks.IsInitialized())
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
if !UNITY_HOLOGRAPHIC
// Diego commented this line and discommented
Window.Current.Activate();
endif
// rootFrame.Navigate(typeof(MainPage));
//**Here is where I update my code**
//**Here is where I update my code**
//**Here is where I update my code**
rootFrame.Navigate(typeof(MyOwnPage));
}
Window.Current.Activate();
}`
In Myown page when I finish my things to do there, I try to call Unity3D so I use the functions suggested in the blog.
private async Task CreateNewHoloWindowAsync()
{
try
{
var appViewId = MainAppViewId = ApplicationView.GetForCurrentView().Id;
var _newCoreAppView = CoreApplication.CreateNewView();
await _newCoreAppView.Dispatcher
.RunAsync(CoreDispatcherPriority.Low,
async () =>
{
var frame = new Frame();
Window.Current.Content = frame;
frame.Navigate(typeof(MainPage));
_newCoreAppView.CoreWindow.Activated += WindowActivated;
_newCoreAppView.CoreWindow.Activate();
var res = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
ApplicationView.GetForCurrentView().Id,
ViewSizePreference.Default, appViewId,
ViewSizePreference.Default);
_newCoreAppView.CoreWindow.Activated += WindowActivated;
_newCoreAppView.CoreWindow.Activate();
});
}
catch (Exception ex)
{
var dialog = new MessageDialog(ex.Message);
await dialog.ShowAsync();
}
}
private void WindowActivated(object sender, WindowActivatedEventArgs e)
{
try
{
if (e.WindowActivationState == CoreWindowActivationState.CodeActivated
|| e.WindowActivationState == CoreWindowActivationState.PointerActivated)
{
AppCallbacks.Instance.SetInitialViewActive();
// Only need to mark initial activation once so unregister ourself
CoreWindow coreWindowSender = sender as CoreWindow;
coreWindowSender.Activated -= WindowActivated;
}
}
catch (Exception ex)
{
var dialog = new MessageDialog(ex.Message);
dialog.ShowAsync();
}
}
Everythings seems to go well, but when the Unity d3d compiled code starts in a new window it suddenly crashes with exception : -2147483645 (0x80000003). There is no more information available. I think I am missing some code with the callbacks but I have no such experience in UWP. Some code that can help me?
User contributions licensed under CC BY-SA 3.0