import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands'; import type { HostComponent, ViewProps } from 'react-native'; import type { DirectEventHandler } from 'react-native/Libraries/Types/CodegenTypes'; export type UnityViewContentUpdateEvent = Readonly<{ message: string; }>; export interface NativeProps extends ViewProps { androidKeepPlayerMounted?: boolean; fullScreen?: boolean; onUnityMessage?: DirectEventHandler; onPlayerUnload?: DirectEventHandler; onPlayerQuit?: DirectEventHandler; } export interface NativeCommands { postMessage: ( viewRef: React.ElementRef>, gameObject: string, methodName: string, message: string ) => void; unloadUnity: (viewRef: React.ElementRef>) => void; pauseUnity: ( viewRef: React.ElementRef>, pause: boolean ) => void; resumeUnity: (viewRef: React.ElementRef>) => void; windowFocusChanged: ( viewRef: React.ElementRef>, hasFocus: boolean ) => void; } export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: [ 'postMessage', 'unloadUnity', 'pauseUnity', 'resumeUnity', 'windowFocusChanged', ], }); export default codegenNativeComponent( 'RNUnityView' ) as HostComponent;