SendMessage Within AddListener #409
-
When I try to call sendMessage from within a listener, I get an error saying that Unity is not instantiated yet. Any Idea how to fix this?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi. Are you using callbacks and effects while adding the right dependencies? Would it be possible for you to share some code, this helps narrowing down the problem. |
Beta Was this translation helpful? Give feedback.
-
The problem was that I was registering my listeners before the Unity element was loaded. To fix this, I moved |
Beta Was this translation helpful? Give feedback.
The problem was that I was registering my listeners before the Unity element was loaded. To fix this, I moved
useUnityContext
to the component that was building the Unity game. I then addedisLoaded
as a dependency for theuseEffect
hook. I also wait to register the listeners untilisLoaded
is true.