Hello,
In my unity project, I have 5 scenes and in each scene I have a couple of NPCs. The user is supposed to go through all 5 scenes one at a time, but there are no orders on which scene is first. For the first 3 scenes everything works as expected but for the last two the avatars do one of these:
the avatar talks but there is no transcript, or
they just don’t answer, or
the avatar moves their hand but there is no lip-sync or sound or transcription!
And it does not matter with what order the scenes are chosen. The problem always happens for the last two scenes.
We’re sorry to hear you’re encountering these issues. Could you please share a video that demonstrates the problem? Make sure the Unity Console is visible in the recording so we can better understand what’s happening. If the video file is large, feel free to upload it to Google Drive or as an unlisted video on YouTube and share the link here or via private message. This will help us investigate and assist you more effectively.
MissingReferenceException: The object of type ‘TextMeshProUGUI’ has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
Hello @Arezoo_Sarshartehran
Can you please let me know which version of Convai SDK and Unity you are using? Also, is any character in your scene under DontDestroyOnLoad?
Hi,
The unity version is: 2022.3.21f1
and the current SDK version is: V3.2.3
Also based on what I checked, there was no character in any scene that was under DontDestroyOnLoad.
Hi again, just wanted to post a quick update in case it helps others:
After digging through the logs and testing a bunch of scene transitions, I finally figured out the source of the problem. The MissingReferenceException was coming from ChatBoxUI.cs—specifically inside the DestroyOldestMessage() method. Basically, the UI was trying to destroy or reference TextMeshProUGUI components that had already been destroyed when switching scenes. This was causing my characters to break in the last two scenes (no transcripts, no audio, just hand gestures).
To fix it, I added a simple null check in DestroyOldestMessage() like this:
private void DestroyOldestMessage()
{
if (_messageList[0].SenderTextObject != null)
Destroy(_messageList[0].SenderTextObject.gameObject);
if (_messageList[0].MessageTextObject != null)
Destroy(_messageList[0].MessageTextObject.gameObject);
_messageList.RemoveAt(0);
}
This makes sure the script doesn’t try to destroy already-missing UI elements. After this change, the NPCs started working again!