Author Topic: UIGrid shifting to the left when I remove object in it?  (Read 2831 times)

ddub

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
UIGrid shifting to the left when I remove object in it?
« on: October 24, 2014, 12:02:11 AM »
Hello all,

Having a strange issue with a ScrollView/Grid set up I have in my scene.

I have a scrollview object as the parent (UIPanel & UIScrollview) and an empty gameobject with UIGrid on it. I have same-sized prefabs instantiated into the grid when user clicks a button. Another button deletes individual prefabs in the grid. Once they're removed, for some reason the UIGrid shifts the Grid object's transform to the left a couple units, each time one is removed.

I call UIReposition and UIPanel refresh after the delete, still no use. Strangely, if I execute the Grid though in the inspector, it returns back to how it should be.

Really strange because I have other grids working totally fine, doing practically the same thing. Any insight on this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIGrid shifting to the left when I remove object in it?
« Reply #1 on: October 25, 2014, 02:21:53 PM »
It's likely in how you are deleting the items. You need to use NGUITools.Destroy, as otherwise the content is still there when you do UIGrid.Reposition. Unity's destroy calls are all delayed until the end of the frame.