AppCallbacks 클래스 레퍼런스
Call the AppCallbacks class in your UWP application.
읽는 시간 4분최근 업데이트: 한 달 전
AppCallbacks예: AppCallbacks 클래스 사용 방법
App.xaml.cpp 파일
App::App(){ InitializeComponent(); SetupOrientation(); m_AppCallbacks = ref new AppCallbacks();}void App::OnLaunched(LaunchActivatedEventArgs^ e){ m_SplashScreen = e->SplashScreen; InitializeUnity(e->Arguments);}void App::InitializeUnity(String^ args){ ApplicationView::GetForCurrentView()->SuppressSystemOverlays = true; 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();}
MainPage.xaml.cpp 파일
MainPage::MainPage(){ m_SplashScreenRemovalEventToken.Value = 0; m_OnResizeRegistrationToken.Value = 0; InitializeComponent(); NavigationCacheMode = ::NavigationCacheMode::Required; auto appCallbacks = AppCallbacks::Instance; bool isWindowsHolographic = false;#if UNITY_HOLOGRAPHIC // If application was exported as Holographic check if the device actually supports it // Otherwise, we treat this as a normal XAML application isWindowsHolographic = AppCallbacks::IsMixedRealitySupported();#endif if (isWindowsHolographic) { appCallbacks->InitializeViewManager(Window::Current->CoreWindow); } else { m_SplashScreenRemovalEventToken = appCallbacks->RenderingStarted += ref new RenderingStartedHandler(this, &MainPage::RemoveSplashScreen); appCallbacks->SetSwapChainPanel(m_DXSwapChainPanel); // Subscribes to all needed system events appCallbacks->SetCoreWindowEvents(Window::Current->CoreWindow); // This is the main initialization function for Unity // Initializes engine graphics, DirectX, and gamepad and joystick input // Loads IL2CPP and all engine subsystems except graphics appCallbacks->InitializeD3DXAML(); // At this point, when Unity finishes loading the first level, it enters the main loop. m_SplashScreen = safe_cast<App^>(App::Current)->GetSplashScreen(); auto dispatcher = CoreWindow::GetForCurrentThread()->Dispatcher; ThreadPool::RunAsync(ref new WorkItemHandler([this, dispatcher](IAsyncAction^) { GetSplashBackgroundColor(dispatcher); })); OnResize(); m_OnResizeRegistrationToken = Window::Current->SizeChanged += ref new WindowSizeChangedEventHandler([this](Object^, WindowSizeChangedEventArgs^) { OnResize(); }); }}
앱 스레드 생성
대형 앱을 로드할 때 UI가 응답하지 않을 수 있으므로 Unity는 UI 스레드에서 앱을 실행하지 않습니다. UI 스레드에 대한 자세한 내용은 UI 스레드 응답 유지에 대한 Microsoft 기술 자료를 참조하십시오.
m_AppCallbacks = ref new AppCallbacks();AppCallbacksApp Thread참고: 및 파일에 있는 코드는 함수에서 호출되지 않는 한 항상 UI 스레드에서 실행됩니다.
App.xaml.cppMainPage.xaml.cppInvokeOnAppThread커맨드 라인 인자
커스텀 커맨드 라인 인자를 문자열 배열로 AppCallbacks 생성자에 전달할 수 있습니다. 자세한 내용은 UWP 커맨드 라인 인자를 참조하십시오.
AppCallbacks 함수
함수 | 설명 |
|---|---|
| DirectX 11 기기를 초기화하고 첫 번째 레벨을 로드합니다. |
| Unity의 핵심 창을 설정합니다. Unity는 다음 시스템 이벤트를 구독합니다. - VisibilityChanged - Closed - PointerCursor - SizeChanged - Activated - CharacterReceived - PointerPressed - PointerReleased - PointerMoved - PointerCaptureLost - PointerWheelChanged - AcceleratorKeyActivated |
| DirectX 11의 렌더 타겟으로 사용되는 XAML 컨트롤을 Unity에 전달합니다. |
| SetSwapChainPanel 메서드를 통해 설정할 수 있는 SwapChainPanel 오브젝트를 반환합니다. |
| 엔진이 메인 게임 루프를 실행할 수 있을 만큼 초기화되었는지 여부를 반환합니다. |
| D3D 애플리케이션의 엔진 그래픽스, DirectX, 게임패드 및 조이스틱 입력을 초기화합니다. |
| 이전에 생성한 AppCallbacks 오브젝트의 싱글톤 인스턴스를 검색합니다. |
| 애플리케이션 스레드의 델리게이트를 호출합니다. 이 함수는 UI 스레드에서 스크립트 함수를 실행하려는 경우에 유용합니다. |
| UI 스레드의 델리게이트를 호출합니다. 이 함수는 스크립트에서 XAML 전용 API를 호출하려는 경우에 유용합니다. |
| 애플리케이션의 첫 번째 레벨이 완전히 로드되면 true를 반환합니다. |
| Unity가 첫 번째 프레임을 렌더링한 후 시작합니다. |
| D3D 애플리케이션이 메인 루프에 진입할 수 있도록 활성화합니다. |
| 현재 애플리케이션 스레드에서 실행 중인 경우 true를 반환합니다. |
| 현재 UI 스레드에서 실행 중인 경우 true를 반환합니다. |
| 애플리케이션 인자를 설정한 다음, UnityEngine.WSA.Application.arguments에서 액세스할 수 있습니다. |
| CoreApplicationView::Activated 이벤트를 구독하고 그래픽스를 제외한 모든 엔진 보조 시스템과 IL2CPP 스크립팅 백엔드를 로드합니다. |
| Unity가 수신하는 입력을 처리하는 경우 true를 반환합니다. |
| 입력 처리를 활성화하거나 비활성화합니다. |
| 1을 통과하면 Unity를 일시 정지하고 0을 통과하면 일시 정지를 해제합니다. 이 함수는 게임을 일시적으로 정지하려는 경우에 유용합니다. |