React Unity WebGL provides a modern solution for embedding Unity WebGL builds in your React Application while providing advanced APIs for two way communication and interaction between Unity and React.
I have a simple light that can be turned on and off via a call similar to:
sendMessage("light", "setOnState", 1)
When I send that exact command, the light turns on as expected. When I send the command with a parameter of 0 - e.g.
sendMessage("light", "setOnState", 0)
I receive this error:
Calling function setOnState with no parameters but the function requires 1.
It seems that the zero is being treated as a null or undefined or similar rather than as a number. I've attempted to cast the zero from text and similar to 'trick' it into sending the zero to the webgl canvas but it isn't working. Any idea how I can work around this? I did some testing by directly interacting with a unity webgl instance in a dev build and was successfully able to turn the light on/off using the commands I've outlined here.
Please avoid duplicates
Language and Compiler
TypeScript's built-in Compiler
What environment are you using?
Local Development Server
When does your problem occur?
When the Unity App is running
What does your problem relate to?
The problem seems React related
React-Unity-WebGL Version
9.5.2
React Version
18.2.0
Unity Version
2022.3.34f1
What happened?
I have a simple light that can be turned on and off via a call similar to:
sendMessage("light", "setOnState", 1)
When I send that exact command, the light turns on as expected. When I send the command with a parameter of 0 - e.g.
sendMessage("light", "setOnState", 0)
I receive this error:
Calling function setOnState with no parameters but the function requires 1.
It seems that the zero is being treated as a null or undefined or similar rather than as a number. I've attempted to cast the zero from text and similar to 'trick' it into sending the zero to the webgl canvas but it isn't working. Any idea how I can work around this? I did some testing by directly interacting with a unity webgl instance in a dev build and was successfully able to turn the light on/off using the commands I've outlined here.
Reproducible test case
No response
Would you be interested in contributing a fix?