azesmway/react-native-unity

String resource ID #0x0

Closed this issue · 2 comments

image

Code:

import React, { useRef, useEffect } from 'react';
import UnityView from '@azesmway/react-native-unity';
import { View, Button, Text } from 'react-native';

interface IMessage {
    gameObject: string;
    methodName: string;
    message: string;
  }

const Unity = ({ navigation }) => {
  console.log('Open Unity')
  const unityRef = useRef(null);
    
    useEffect(() => {
      if (unityRef.current) {
        const message: IMessage = {
          gameObject: 'gameObject',
          methodName: 'methodName',
          message: 'message',
        };
        unityRef.current.postMessage(message.gameObject, message.methodName, message.message);
      }
    }, []);
    
    return (
      <View style={{ flex: 1 }}>
        <Button title='Go back Home' onPress={() => navigation.navigate('Home')} />
        <UnityView
          ref={unityRef}
          style={{ flex: 1 }}
          onUnityMessage = {(result) => { console.log('onUnityMessage', result.nativeEvent.message) }}
        />
      </View>
    );
    
};

export default Unity;

Seems like my project has problem with unityRef/UnityView.

without
<UnityView ref={unityRef} style={{ flex: 1 }} onUnityMessage = {(result) => { console.log('onUnityMessage', result.nativeEvent.message) }} />
project seems to work fine.
image

Any idea how to fix it?

@BedkowskiP What did you do to fix it? Getting the same error

This fix can be found in step 5 of the README instructions for setting up android. No sweat for missing it, I missed it for quite some time as we;;