Mixedrealitytoolkit-unity: What is a right way to delete object from Scrolling Object Collection?

Created on 16 Jun 2020  路  6Comments  路  Source: microsoft/MixedRealityToolkit-Unity

I want to add and remove objects inside Scrolling Object Collection.
Adding is not a problem, but when i am trying to remove object using this code:
Destroy(ScrollBar.Find("Container").Find("test3")?.gameObject); ScrollBar.GetComponent<ScrollingObjectCollection>().UpdateCollection()
I get this:
image
and also exceptions:

MissingReferenceException: The object of type 'BoxCollider' 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.
Microsoft.MixedReality.Toolkit.Experimental.UI.ScrollingObjectCollection.HideItems () (at Assets/MRTK/SDK/Experimental/ScrollingObjectCollection/ScrollingObjectCollection.cs:1664)
Microsoft.MixedReality.Toolkit.Experimental.UI.ScrollingObjectCollection.LateUpdate () (at Assets/MRTK/SDK/Experimental/ScrollingObjectCollection/ScrollingObjectCollection.cs:1038

Is there a better way to remove object?

Specs: Unity 2018.4, MRTK 2.4.0, Hololens 1st gen

Documentation

All 6 comments

@vaoliva @thalbern as we talk about doing scrolling object collection graduation.

@wiwei Adding this issue to the scroll graduation list.

We have a similar issue if we disable the Collection object and try to reenable it later on. All objects that were in a "masked" state when the object is disabled, remain disabled on reenabling the collection object and the same error gets thrown:

"MissingReferenceException: The object of type 'BoxCollider' 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."

We have a similar issue if we disable the Collection object and try to reenable it later on. All objects that were in a "masked" state when the object is disabled, remain disabled on reenabling the collection object and the same error gets thrown:

@tank-t-bird Could you please open a different issue with more info for the reenabling problem you are facing? I have tried to replicate your steps but I couldn't reproduce the error.

Closing as fixed on #8154

i made a fix

Destroy (object);
after that Invoke("method name ",0.5f);

call scrolling object collection (). updatecollection(); from that new function

this will make fix

Was this page helpful?
0 / 5 - 0 ratings