bevyengine / bevyengine/bevy

Create UIViewController in iOS bevy event loop

Open
#9,997 0 comments 0 reactions 0 assignees View on GitHub
A-Windowing C-Usability O-iOS
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

First and foremost, I apologize for my limited knowledge of the framework's intricate details.

While I understand that this question might be more suited for the winit library, Bevy internally utilizes winit to manage its event loop. Therefore, it seems logical for Bevy to offer access to these underlying components so users can adjust or modify them as needed.

In my specific scenario, when using Bevy with iOS, I believe it internally initializes a UIApplicationMain which manages the event loop and is in charge of rendering views. However, I've encountered a challenge. I need to introduce an additional ViewController to display an ad via Google AdMob. Attempting to run another UIApplicationMain results in a crash since an event loop is already active, and we can't have two running on the same main thread.

If Bevy could provide direct access to winit's components, it might allow users like myself to adjust the behavior to access the UIWindow and reuse the same components to introduce new ViewControllers.

This the best I manage to do in bevy app

```
fn setup_raw_window(mut windows: NonSend, window_query: Query>) {
let entity = window_query.single();
let raw_window:&window::Window= windows.get_window(entity).unwrap();
}
```

But I don't know how to cast the `Window` to `WindowExtIOS`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.