Callback in Unity not working #256
-
Hi all, i'm having an issue getting React to send a message back to Unity for some reason... I am using Unity 2019 and v7 of the library. The call from Unity to React works just fine. My React code is: async function server_login() {
try {
await ual.showModal();
console.log('User Account:' + ual.users[0].accountName);
console.log('Calling WalletController');
unityContent.send(
"WalletController",
"Server_Response_LoginData",
ual.users[0]?.accountName
);
} catch (error) {
console.log('server_login Error:' + error);
}
} and on the Unity side I have:
Everything up to the console.log('Calling WalletController') works fine, but nothing seems to come back to Unity. What might I be doing wrong? Also, why does some documentation refer to UnityContext and others refer to UnityContent? I tried switching to UnityContext but that wouldn't compile. Regards |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Hi. Ar you sure |
Beta Was this translation helpful? Give feedback.
-
Oh and about your Content/Context question, this has been refactored in version 8.x. You should refer to the 7.x documentation instead of you are using Unity 2019. You can find it here. |
Beta Was this translation helpful? Give feedback.
Hi. Ar you sure
ual.users[0]?.accountName
returns an actual string? Because it it returns undefined due to the optional chaining, the module handles it as if there was no parameter which meanspublic void Server_Response_LoginData()
would be invoked rather thanpublic void Server_Response_LoginData(string account)
with a string parameter.