What would a better way look like? So, the perfect way would be to not have a browser, to still have React Native code or React-like code that is then being fed to some sort of a native runtime just like on mobile that has a native integration with all the native game engine constructs and would render a frame that has the UI on top of it. Before I show my integration, I want to say that you've probably already interacted with something like this. This is not a completely new idea. This is an idea that has been explored, and I think some of you will be surprised to hear that, but if you own a PlayStation, you are playing around with a React Native UI on the PlayStation. So, the whole entire PlayStation UI, the whole entire main PlayStation experience with all the apps is actually a collection of dozens and dozens of React Native apps that are being rendered in 3D. So, to recap, until now, when we wanted to use web technologies in games, we would do it in a way that resembles apps before 2015. We would grab HTML components, render them inside of a web view, and my hope is that after this conference, we can think of it similar to how the conference in 2015 opened up new ways of building things. We could think in terms of native slate components in Unreal Engine that are natively rendered by the platform, but while we are doing that, we can also still write JavaScript and TypeScript code.
How does that work? How would a system like this work? React Native has something called platforms. In-tree platforms and out-of-tree platforms. So, if you've been building any React Native code for iOS and Android, you're familiar with the fact that there is a C++ core that is being compiled to a shared object and then being distributed with bindings to the native platforms. What you might not be as familiar with is that there are out-of-tree platforms like Mac OS and Windows being developed by Microsoft and Vision OS, which I think is being made by Callstack currently. These are also in a surprising amount of places. I've heard that if you currently click on the start menu in Windows, you're interacting with the React Native mini application that powers the start menu. So, my proposition is an Unreal Engine out-of-tree platform. That platform is then packaged as a standard Unreal Engine plugin. This plugin has bindings for all the different React systems. So, React has native core components like a scheduler, surface manager. It has a React host class that helps bootstrap everything. It has interfaces for HTTP, WebSocket, timer, all sorts of native API functionality. All of that is satisfied by this Unreal Engine native React plugin. All of that talks to the game. With this kind of architecture, we can then take the familiar React views, the familiar React text components, image components, and then translate them directly to slate components, such as React views, React paragraphs, React images, which are just child components, child classes of regular native slate components. That sounds great. I have been working on this for quite a while, and until now, everything is easy peasy, but reality is not so fast, not so easy. The first challenge to make all of this work was that React Native currently assumes that you're going to be working with iOS and Android, despite the existence of many out-of-tree platforms. If you're trying to build a React Native codebase for C++, it's going to assume one of two things. Either you're building for Android or you're building for something called Phantom, which is a private meta headless tester that they use to confirm that the core code is working as it should. The solution to this was a lot of ugly CMake lists overrides, and I'm going to use this platform to say that it would be nice if meta made the build system more modular, because I think that out-of-tree platforms are a big part of the future. There are many more platforms that are mature and would benefit from an integration with React Native.
Comments