Author Topic: UIScrollView.uipanel not draw children, but draw by UIPanel in parent  (Read 1525 times)

chiuan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 6
  • Posts: 11
    • View Profile
 :'(

  1.         void refreshServerList()
  2.         {
  3.                 for(int i =0 ; i < PomeloManager.Self.gameServerList.Count; i++)
  4.                 {
  5.                         createServerItem(PomeloManager.Self.gameServerList[i]);
  6.                 }
  7.                 //tableServer.repositionNow = true;
  8.                 tableServer.Reposition();
  9.                 scrollViewServer.ResetPosition();
  10.         }
  11.  
  12.         void createServerItem(PomeloManager.GameGate gate)
  13.         {
  14.                 //GameObject go = Instantiate(templateServerItem.gameObject) as GameObject;
  15.                 //go.transform.parent = tableServer.transform;
  16.                 //go.transform.localScale = Vector3.one;
  17.  
  18.                 GameObject go = NGUITools.AddChild(tableServer.gameObject, templateServerItem.gameObject);
  19.                 go.SetActive(true);
  20.                
  21.                 UIGameServerItem item = go.GetComponent<UIGameServerItem>();
  22.                 item.gate = gate;
  23.                 serverItems.Add(item);
  24.         }
  25.  

scroll(Contain UIPanel & UIScrollView Components) nothing show On Drawcall popup window. but, i found the children all draw by 3_ServerList(UIPanel).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView.uipanel not draw children, but draw by UIPanel in parent
« Reply #1 on: January 06, 2014, 10:23:36 AM »
Use NGUITools.SetActive instead of go.SetActive. GameObject.SetActive activates children before parents, which is a long-standing bug in Unity.