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 been working on a project where I am using wit.ai for voice recegnition in a scene that can be loaded, exited, and reloaded. I noticed that on the first time the scene was loaded (whether it be as the first scene or through SceneManager.LoadScene), my wit.ai connection works fine with my Wit script being the base of the functionality, being activated and used to recognize voice. I noticed that if I exit the scene and reload it, every time I get a nullReferenceException in WitService on line 155, stemming from Wit.cs line 91.
NullReferenceException: Object reference not set to an instance of an object
Facebook.WitAi.WitService.OnEnable () (at Library/PackageCache/com.facebook.witai@07b625a78e/Scripts/Runtime/WitService.cs:155)
UnityEngine.GameObject:AddComponent()
Facebook.WitAi.Wit:Awake() (at Library/PackageCache/com.facebook.witai@07b625a78e/Scripts/Runtime/Wit.cs:91)
Past this point, every time that Wit.Activate() is called in order to obtain voice input, this occurs:
Everything I try to work around this exception ends up landing me with a similar nullReferenceException, always having something to do with the AudioBuffer. Is there something I am missing in terms of leaving and entering scenes with Wit.cs?
Here are steps to reproduce this:
Open an empty unity3d project.
Import this SDK via github url.
Make two copies of the "ResponseDebugger" sample scene in your assets.
Add each of these to the Scenes in build via build settings.
Add a button to each scene tied to a script which loads the other duplicate scene. (just use UnityEngine.SceneManagement and SceneManager.LoadScene(int)).
Generate the wit configuration asset using the server access token for any app, then attach that to the "Wit" prefab in the ResponseDebugger scenes.
Press "play" with one of the scenes open and click "activate mic", validating that Wit is working normally with voice input by retrieving feedback. Make sure the "activate mic" button is tied to Wit.Activate().
Click the placed button to go to the other scene.
Note the NullReferenceException that occurs due to Wit activation.
Note that if you click "Activate Mic", the same exceptions keeps occuring.
You can load back to the first scene and note that despite it working initally, the same error is now being passed.
This problem is really slowing down the progress of my projects and I hope a fix exists.
The text was updated successfully, but these errors were encountered:
phillipsalbright
changed the title
NullReferenceException when re-loading/activating wit
NullReferenceException when re-loading scene and activating wit
Jul 6, 2022
phillipsalbright
changed the title
NullReferenceException when re-loading scene and activating wit
NullReferenceException when re-loading scene and re-activating wit
Jul 6, 2022
Hello, do you still have the same problem? I found the solution. When you change scene, the AudioBuffer is destroyed(the object) and not created. You must add DontDestroyOnLoad(this.gameObject) when it is created or have it created again when a scene is loaded.
I have been working on a project where I am using wit.ai for voice recegnition in a scene that can be loaded, exited, and reloaded. I noticed that on the first time the scene was loaded (whether it be as the first scene or through SceneManager.LoadScene), my wit.ai connection works fine with my Wit script being the base of the functionality, being activated and used to recognize voice. I noticed that if I exit the scene and reload it, every time I get a nullReferenceException in WitService on line 155, stemming from Wit.cs line 91.
Past this point, every time that Wit.Activate() is called in order to obtain voice input, this occurs:
Everything I try to work around this exception ends up landing me with a similar nullReferenceException, always having something to do with the AudioBuffer. Is there something I am missing in terms of leaving and entering scenes with Wit.cs?
Here are steps to reproduce this:
This problem is really slowing down the progress of my projects and I hope a fix exists.
The text was updated successfully, but these errors were encountered: