Facing an issue once i switch the scene

Hi im facing an error where i switch my environment from one to second.In second environment i have video texture where videos is wokring but once i switch the second environment then im facing this error


Can you help me thanks

Hi @regeme! Can you share a link of your project please?

Thanks for the reply the project is private but I can show the script where I change the scene

I don’t see how the error is related to that part of code. Can you share the code of the error please? May I also ask wht you don’t use line 37 to change the scene?

I use it but once the switch to the second scene then the pic which I show you got me an error

Alright, can you share the code that gives the error?

16 line no of code once I switch the scene

Does the entity with the script in the new scene also has an element component?

Its the element component in new scene but this script is not using in the first scene

Can you show the entity with the script and the element component please? Can it be that another entity without an element component has also the script attached?

In first scene this script is not initialize because I don’t need it but once I change the scene or switch 1 to 2 then I face this issue even in second scene I inintialize the script and add the entity as well

I like to see the entity that has the element component and the script that gives the error.

Hi @Yash,

It looks the reason for this error (without seeing the project) is your use of app level events while switching scenes. Because the original event listener from the first screen is still active, but the scene and all of it’s contents have been destroyed, the browser can no longer find the original objects it was supposed to interact with.

You will want to make sure that you are unsubscribing from that particular app event upon destroying the scene, and then re-subscribe when the new scene loads. Check out this thread for some basic pseudo-code:

I hope this is helpful.

2 Likes