你好,
一个简单的解决方案是在生成UWP项目时将 Build Type 设为 D3D 而非 XAML。
DirectX 应用程序不会有鼠标和白边的问题。
如果你需要使用XAML类型的程序,你可以在生成的UWP项目中找到 App.xaml.cpp 文件并添加如下代码:
App::App()
{
InitializeComponent();
SetupOrientation();
//关闭鼠标模式
RequiresPointerMode = ApplicationRequiresPointerMode::WhenRequested;
m_AppCallbacks = ref new AppCallbacks();
}
void App::InitializeUnity(String^ args)
{
ApplicationView::GetForCurrentView()->SuppressSystemOverlays = true;
//扩展UI到屏幕边缘
ApplicationView::GetForCurrentView()->SetDesiredBoundsMode(ApplicationViewBoundsMode::UseCoreWindow);
m_AppCallbacks->SetAppArguments(args);
auto rootFrame = safe_cast<Frame^>(Window::Current->Content);
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == nullptr && !m_AppCallbacks->IsInitialized())
{
rootFrame = ref new Frame();
Window::Current->Content = rootFrame;
#if !UNITY_HOLOGRAPHIC
Window::Current->Activate();
#endif
rootFrame->Navigate(TypeName(MainPage::typeid ));
}
Window::Current->Activate();
}
详细信息请参见:
- 如何禁用鼠标模式
- 如何将 UI 绘制到屏幕的边缘