Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Aethelwulf on March 21, 2014, 11:59:00 PM

Title: C# Setting UITable children spacing in code & widget depth problem (bug)?
Post by: Aethelwulf on March 21, 2014, 11:59:00 PM
I have the following UITable which seems to go a little wonky with the spacing. How does one properly set the spacing of UITable children? When using transform.position or localPosition, the UITable children pos will reset as soon as I use repositionNow.

  1.  
  2. GameObject itemGridView = GameObject.Find("Grid View Table");
  3. UITable table = (UITable)itemGridView.GetComponent(typeof(UITable));
  4.  
  5. for(int x = 0; x < numOfHorizontalItemHolders; x++)
  6. {
  7.        GameObject go = NGUITools.AddChild(itemGridView,itemHolder);
  8.        [....]
  9.  
  10. }
  11. table.repositionNow = true;
  12.  


*edit* OK I've fixed it by playing with the padding. If you set it to negative value, it decreased cell spacing. This has created two new problems.

- The layering/widget depth doesn't seem to work. No matter whether I set the UISprite depth via editor, in code, or by changing the transform z position, the layering of the item boxes (boxes in inventory below - hard to see due to wrong depth) seem to be stuck at a depth behind the inventory panel UISprite.

- When placing a gameobject with UISprite as a child of one of these boxes (as you see in image below) and then calling repositionNow = true on the UITable to add that object into the UITable collection, the newly added gameobject does not fall within the table until the renderer is disabled and reenabled. Could this be a bug? When scrolling up and down on the table, the new table gameobject also does not fall behind the softclip until the entire table is disabled and reenabled - which I'm assuming is because it isn't added to the UITable collection until after disable/enable bug.

(http://i.imgur.com/HZaFODx.png)
Title: Re: C# Setting UITable children spacing in code & widget depth problem (bug)?
Post by: ArenMook on March 22, 2014, 02:56:04 PM
Widget depth sorts widgets that belong to the same panel.

If widgets belong to different panels, they are sorted by panel depth first. All panels gather widgets that belong to them, and they never mix.