Missing Ref Exception when deleting Obi Cloth - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html) +--- Thread: Missing Ref Exception when deleting Obi Cloth (/thread-2769.html) |
Missing Ref Exception when deleting Obi Cloth - fluidman84 - 26-02-2021 I've encountered this error when I attempt to Destroy() a obi cloth object in the scene that has been instantiated and then create a new obi cloth object in its place. This issue does not occur if I Destroy the object first then instantiate a new one afterward in a separate method, but I cannot perform the Destruction in the same method without receiving this error for the missing ObiSkinnedClothBlueprint. Is there a way I can disable this one the obi cloth to be destroyed to prevent this error? Code: MissingReferenceException: The object of type 'ObiSkinnedClothBlueprint' has been destroyed but you are still trying to access it. RE: Missing Ref Exception when deleting Obi Cloth - josemendez - 27-02-2021 (26-02-2021, 09:45 PM)fluidman84 Wrote: I've encountered this error when I attempt to Destroy() a obi cloth object in the scene that has been instantiated and then create a new obi cloth object in its place. This issue does not occur if I Destroy the object first then instantiate a new one afterward in a separate method, but I cannot perform the Destruction in the same method without receiving this error for the missing ObiSkinnedClothBlueprint. Is there a way I can disable this one the obi cloth to be destroyed to prevent this error? Hi, can you post the code that results in this error? keep in mind that Destroy() does not destroy the object immediately, it just marks it for destruction at the end of the frame. This can lead to subtle bugs. RE: Missing Ref Exception when deleting Obi Cloth - fluidman84 - 28-02-2021 Hi Jose, Here is the code that is loading Asset Bundles and resulting the error when attempting to Destroy the instance from the Asset Bundle. Code: public GameObject femModel; If I call the DeleteClothingItem separately everything works fine. It's only when calling DeleteClothingItem while InstatiateObjectFromBundle in same method that the error and subsequent crash occurs. RE: Missing Ref Exception when deleting Obi Cloth - josemendez - 02-03-2021 Hi there! I've been testing your code, but I'm so far unable to reproduce the issue. This is the setup I have: - Created an AssetBundle out of a few cloth prefabs. - Empty scene, one GameObject with your script (named BundleLoader). Added a call to LoadOutfitAssetBundle() in its Awake() method, added a couple calls to LoadOutfitBundlePrefab() in Update(), passing different prefab names whenever I press various keyboard keys like so: Code: public void Update() - Created a ObiSolver+FixedUpdater GameObject, passing it to your script as the "FemModel". This way, prefabs are instantiated under the solver and simulated right away. - Run the scene, press the prefab keys at random to load a new prefab each time, unloading the previous one. Works fine, no errors pop up. can you spot any appreciable difference with what you're doing? cheers, Quote:If I call the DeleteClothingItem separately everything works fine. It's only when calling DeleteClothingItem while InstatiateObjectFromBundle in same method that the error and subsequent crash occurs. I don't see any difference when calling them separate + together. Unless they're called at different points in time (different frames, by using a coroutine, or just calling them in response to different user input) there's no actual difference in calling them in the same method or different methods. RE: Missing Ref Exception when deleting Obi Cloth - fluidman84 - 03-03-2021 Thank you for testing that! Yes, after you verified the execution order I found that the loaded Asset Bundle was being destroyed before the prefab was instantiated to the scene. Once I changed the execution order of the instance and the destroy commands, everything is working as it should. RE: Missing Ref Exception when deleting Obi Cloth - josemendez - 04-03-2021 (03-03-2021, 08:20 PM)fluidman84 Wrote: Thank you for testing that! Glad you got it working! |