Reputation: 1
I'm trying to embed a Unity project into a React Native Expo app using the react native unity package. Despite following the setup steps in the README, I'm encountering an error when navigating to the screen containing the Unity view.
Setup Details:
React Native Expo version: Created using npx create-expo-app@latest
.
Unity version: 2022.3.42f1
React Native Unity package version: Latest version (tried both latest and 1.0.7 as recommended in a tutorial).
Unity build path: Exported to 'unity/builds/android' at the root of the React Native project.
Steps I Followed:
import React, { useRef } from 'react';
import UnityView from '@azesmway/react-native-unity';
import { View } from 'react-native';
const Unity = () => {
const unityRef = useRef<UnityView>(null);
return (
<View style={{ flex: 1 }}>
<UnityView
ref={unityRef}
style={{ flex: 1 }}
/>
</View>
);
};
export default Unity; 3. Added this screen to a navigation stack. 4. Ran the app using npx expo start.
The Issue:
The app runs fine initially, but when I press the button to navigate to the screen containing Unity, the following error occurs:
ViewManagerResolver returns null for either RNUnity or RCTRNUnityView
What I Tried: Followed the steps from the react-native-unity GitHub README. Followed the tutorial in this Medium article. Installed the 1.0.7 version of react-native-unity, as recommended in the article.
Upvotes: 0
Views: 827
Reputation: 1
I also encountered the same error but with a different package. I resolved it by changing newArchEnabled
to false in app.json and rebuilding the development app with eas build --platform android --profile development
. Don't forget to clear the cache when starting Expo with npx expo start -c
.
Upvotes: 0