Author Topic: wrap content scroll view Transform error  (Read 1962 times)

firestorm

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
wrap content scroll view Transform error
« on: November 12, 2015, 03:08:21 AM »
I have a store set up that is just items in a scroll view. I want to delete the item if the player owns that item already. The issue is I get this error when you attempt to scroll through the items after them being deleted

MissingReferenceException: The object of type 'Transform' 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.
UnityEngine.Transform.get_localPosition () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineTransformBindings.gen.cs:34)
UIWrapContent.WrapContent () (at Assets/NGUI/Scripts/Interaction/UIWrapContent.cs:180)
EventDelegate.Execute () (at Assets/NGUI/Scripts/Internal/EventDelegate.cs:476)
EventDelegate.Execute (System.Collections.Generic.List`1 list) (at Assets/NGUI/Scripts/Internal/EventDelegate.cs:644)
UIButton.OnClick () (at Assets/NGUI/Scripts/Interaction/UIButton.cs:248)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
UICamera:Notify(GameObject, String, Object) (at Assets/NGUI/Scripts/UI/UICamera.cs:1469)
UICamera:ProcessRelease(Boolean, Single) (at Assets/NGUI/Scripts/UI/UICamera.cs:2325)
UICamera:ProcessTouch(Boolean, Boolean) (at Assets/NGUI/Scripts/UI/UICamera.cs:2375)
UICamera:ProcessMouse() (at Assets/NGUI/Scripts/UI/UICamera.cs:1830)
UICamera:ProcessTouches() (at Assets/NGUI/Scripts/UI/UICamera.cs:1943)
UICamera:Update() (at Assets/NGUI/Scripts/UI/UICamera.cs:1631)


I have attempted to run the WrapContent() after deleting the item and the scroll views ResetPosition() with same results

any help would be appreciated

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: wrap content scroll view Transform error
« Reply #1 on: November 12, 2015, 08:59:16 PM »
UIWrapContent script caches the list of transforms. If you delete some, then the wrap content's list will be invalid. The caching of transforms is done when calling SortAlphabetically() or SortBasedOnScrollMovement() functions. Just call one of them after deleting your transforms (my guess - alphabetically in your case?)