You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have kept androidKeepPlayerMounted this false , so first time unity loads but when i navigate to any other screen and come back again to unity screen then unity does not load below is the code. Thank you for taking a look.
import {
ImageBackground,
StatusBar,
Image,
TouchableOpacity,
View,
TextInput,
SafeAreaView,
Button,
} from 'react-native';
import React, {useRef, useEffect, useState} from 'react';
import Images from '../../../Styles/Images';
import styles from './Styles';
import UnityView from '@azesmway/react-native-unity';
import {useNavigation, useFocusEffect} from '@react-navigation/native';
import Styles from '../../Auth/Login/Styles';
import {Colors} from 'react-native/Libraries/NewAppScreen';
export default function FaceInteraction(props): React.JSX.Element {
const {navigation} = props;
const unityRef = useRef(null);
const [message, setMessage] = useState('');
const [showTextField, setShowTextField] = useState(false);
console.log(unityRef);
const handleInputChange = inputValue => {
setMessage(inputValue);
};
const submitHandler = () => {
const unityData = {
name: message,
age: 3,
};
let jsonedData = JSON.stringify(unityData);
console.log(unityData)
SendData(jsonedData);
};
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
async function SendData(data: any) {
await delay(500);
console.log('data is sended from react native');
unityRef.current?.postMessage('ReactToUnity', 'GetDatas', data);
}
I have kept androidKeepPlayerMounted this false , so first time unity loads but when i navigate to any other screen and come back again to unity screen then unity does not load below is the code. Thank you for taking a look.
import {
ImageBackground,
StatusBar,
Image,
TouchableOpacity,
View,
TextInput,
SafeAreaView,
Button,
} from 'react-native';
import React, {useRef, useEffect, useState} from 'react';
import Images from '../../../Styles/Images';
import styles from './Styles';
import UnityView from '@azesmway/react-native-unity';
import {useNavigation, useFocusEffect} from '@react-navigation/native';
import Styles from '../../Auth/Login/Styles';
import {Colors} from 'react-native/Libraries/NewAppScreen';
export default function FaceInteraction(props): React.JSX.Element {
const {navigation} = props;
const unityRef = useRef(null);
const [message, setMessage] = useState('');
const [showTextField, setShowTextField] = useState(false);
console.log(unityRef);
const handleInputChange = inputValue => {
setMessage(inputValue);
};
const submitHandler = () => {
const unityData = {
name: message,
age: 3,
};
let jsonedData = JSON.stringify(unityData);
console.log(unityData)
SendData(jsonedData);
};
const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
async function SendData(data: any) {
await delay(500);
console.log('data is sended from react native');
unityRef.current?.postMessage('ReactToUnity', 'GetDatas', data);
}
useEffect(() => {
return () => {
unityRef.current?.componentWillUnmount();
};
}, []);
return (
<View style={{backgroundColor: 'black'}}>
<UnityView
ref={unityRef}
style={{ height: 100%', width: '100%'}}
androidKeepPlayerMounted={false}
onUnityMessage={result => {
console.log('Message Here : ', result.nativeEvent.message);
let d = result.nativeEvent.message;
if (d.includes('home')) {
navigation.navigate('BottomNavigation', {screen: 'HomeTab'});
}
}}
/>
);
}
The text was updated successfully, but these errors were encountered: