Author Topic: Draggable UIPanel not seeing added widgets  (Read 10942 times)

Disastercake

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 87
  • www.disastercake.com
    • View Profile
    • Disastercake
Re: Draggable UIPanel not seeing added widgets
« Reply #15 on: July 12, 2012, 07:50:08 PM »
I see this line:

  1. mTrans.BroadcastMessage("CheckParent", SendMessageOptions.DontRequireReceiver);
  2.  

What is the difference between Broadcast and mTrans.Broadcast in that script?  Does Broadcast only broadcast to a specified object that the method instance belongs to?
Creator of Soul Saga.
http://www.disastercake.com

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Draggable UIPanel not seeing added widgets
« Reply #16 on: July 12, 2012, 08:11:17 PM »
I was just referring to BroadcastMessage.

cfj

  • Guest
Re: Draggable UIPanel not seeing added widgets
« Reply #17 on: July 12, 2012, 09:47:23 PM »
It is not just the Invoke method.  I did some more research. 

When using a Draggable UIPanel, the ONLY time I was able to get the button to render when using NGUITools.AddChild was using it in Awake, Start or the FIRST CALL of Update (first frame).  I thought calling it in Update was fine but I only tried it on the first frame.  If you call it in Update at any other time either by using a counter, using Invoke, or using a GetKey command to execute the command after the first frame, it will not render the button.  It creates it, but will not render it until you scroll the UIPanel or adjust it in some way.

Knowing this, is there a way to create widgets dynamically on draggable UIPanels and have the widgets render without adjusting the panel?



cfj

  • Guest
Re: Draggable UIPanel not seeing added widgets
« Reply #18 on: July 12, 2012, 11:14:53 PM »
Finally thought to look at the code of UIDraggablePanel (head ... bang ... on ... desk).  I got it working by using ResetPosition().  Although it is not ideal since it is moving the clipping box around where I don't want it to be at the top left of the widgets.  I could also get it working by using Scroll(0.001f) but that seems very hackish to me.

It seems to me this works because it replicates the behavior that causes it to finally render. 
1) ResetPosition adjusts the clipping box (which is the same as me doing it in the inspector) which causes it to render.
2) Scroll(0.001f) literally scrolls the panel just a bit (which is the same as me scrolling it in game) which causes it to render.

Out of curiosity, is there a way to get new widgets in a draggable panel to render without scrolling it or adjusting the clipping box?


joreldraw

  • Guest
Re: Draggable UIPanel not seeing added widgets
« Reply #19 on: July 13, 2012, 03:29:23 AM »
Is this your problem?

I have same issue and i not add in execution time, my hierachy is predefined in editor.

Video: http://www.tasharen.com/forum/index.php?action=dlattach;topic=641.0;attach=213
Post: http://www.tasharen.com/forum/index.php?topic=641.msg3292#msg3292

I try refreshing table, repositioning and a lot of options with the clipping panel and nothing fix. But at this time on Android work fine from first time i open, but not on Desktop.

Pdta: Only appear this fail when the dragable panel not have objects to fill and be dragable.
« Last Edit: July 13, 2012, 03:31:55 AM by joreldraw »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Draggable UIPanel not seeing added widgets
« Reply #20 on: July 13, 2012, 08:45:16 AM »
Is your panel marked as "static" perchance? "Static" flag toggled on the UIPanel (on the UIPanel, not the game object) tells the panel that the geometry will not change, and it will ignore your widget changes.

cfj

  • Guest
Re: Draggable UIPanel not seeing added widgets
« Reply #21 on: July 13, 2012, 01:22:31 PM »
Ah Ha!  That worked for me.  I thought I had tried adjusting that before and didn't see a difference.  Oh well, it works now.  Since the hint for Static is "Check if widgets don't move", I just left it on like Example 7 since the widgets don't move, the panel does.  But I understand now that it will prevent dynamic widgets showing.

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Draggable UIPanel not seeing added widgets
« Reply #22 on: July 13, 2012, 02:18:13 PM »
Disastercake had the same problem with his project. Because of you two I've added an extra check to the panel that will ensure that this works in the future.