- Home /
How to disable DontDestroyOnLoad on throwables?
Somehow, my interactable and throwable objects are automatically set to "DontDestroyOnLoad" whenever I interact with them (throw, grab, etc). I don't want these items when a new scene is loaded, and I can't trace what function in the "Throwable" script calls the "DontDestroyOnLoad" script.
I looked at the Throwable objects in SteamVR's default "Interactions Example" Scene, and their throwables don't have the same issue as mine, despite everything in the Inspector looking exactly identical.
Bent head over heels over this issue. Kindly advise.
@FarzanaJeffri96 Are there any results for a full-text search across all of S$$anonymous$$mVR's script for the string "DontDestroyOnLoad"?
Yeah, in five scripts: S$$anonymous$$mVR_LoadLevel, Singleton, ChaperoneInfo, S$$anonymous$$mVR_Behaviour. After a quick debug, most likely it's caused by the script in S$$anonymous$$mVR_Behaviour, however, I would want to refrain from doing any direct changes to S$$anonymous$$mVR's scripts....and it doesn't make sense either since this problem doesn't apply to the interactables in the Interactions Example scene...
@FarzanaJeffri96 Can you create a copy of your scene and a copy of the Interactions Example scene, then reduce both to the smallest reproducible example, and see where they might differ?
I've been working on porting a project over from Oculus to use S$$anonymous$$mVR ins$$anonymous$$d and had a similar issue with objects in the scene being set to "DontDestryOnLoad". The problem was because there is a script ("S$$anonymous$$m VR_Behaviour") in the Player prefab that was set to "Do Not Destroy". The script in question was located in the prefab under S$$anonymous$$mVRObjects->[S$$anonymous$$mVR]. Turing the toggle off on the script fixed the issue for me.
Your answer
Follow this Question
Related Questions
How to stop objects you picked up from reappearing when you go to another level and return 1 Answer
Can I add an exemption on DontDestroyOnLoad? 1 Answer
Getting MissingReferenceException on Canvas text even though I used DontDestroyOnLoad 1 Answer
How do I transfer a gameobject created in one scene to another scene AND use it in a c# script? 1 Answer
Execution order of Destroy() and DontDestroyOnLoad() between Scenes 0 Answers