Author Topic: BUG(?): UIPanel.Refresh not refreshing "completely"  (Read 6659 times)

helmesjo

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 116
    • View Profile
BUG(?): UIPanel.Refresh not refreshing "completely"
« on: May 23, 2013, 04:09:14 AM »
Just found a strange behaviour... I got my own table with reusable cells (something like how Android and iOS does it), which on reload will calculate positions etc. in a grid for all the cells. However, the panel used for the table will draw the first cell before it's been positioning correctly (I'm guessing), causing this glitch where the widget itself is in the correct position (as seen from the gizmos), but the actual drawn graphic is not (drawn at the "old" position, since the table won't know how wide it will be at first cell so it will recenter when more columns gets loaded and so on. Just think of it as a lot of widgets being instantiated and moved around).

Hard to explain, but what I found was that calling UIPanel.Refresh did nothing (widget still not redrawn in correct position), but adding widget.MarkAsChangedLite() in the UIPanel.Refresh-method in the forloop did the trick. Not sure how Refresh is supposed to work, but I read it as a "Total, clean and brutal refresh of the panel, inefficient but used when necessary", if you know what I mean :)

Anyways, I will use my fix for now but thought you would like to know about this issue (?). I don't really have time to create a reprocase atm, got a deadline incoming... Sorry!

Cheers!
« Last Edit: May 28, 2013, 12:23:33 PM by helmesjo »

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIPanel.Refresh not refreshing "completely"
« Reply #1 on: May 23, 2013, 07:14:18 AM »
This will force a real true and brutal refresh:

  1. myGameObject.BroadcastMessage("CreatePanel", SendMessageOptions.DontRequireReceiver);

helmesjo

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 116
    • View Profile
Re: UIPanel.Refresh not refreshing "completely"
« Reply #2 on: May 27, 2013, 02:43:27 AM »
Thanks Nicki, that is ofc also an option. Though the point with this thread was to hopefully get this implemented into NGUI so refresh works as expected (or is it just my super-special case?) and make the code look cleaner.
Anyone know at hand if it's quicker to broadcastmessage on a certain method or getcomponentsinchildren and then invoke the individual methods in a for/foreach? Somehow the latter seems worse since typecasting etc. is involved, but then again I have no insight into how broadcast actually operates...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPanel.Refresh not refreshing "completely"
« Reply #3 on: May 27, 2013, 11:24:40 AM »
Panel's Refresh() will refresh the draw calls, but only of the widgets that have been registered with the panel. MarkAsChanged registers the widget with the panel.

helmesjo

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 116
    • View Profile
Re: UIPanel.Refresh not refreshing "completely"
« Reply #4 on: May 28, 2013, 06:57:00 AM »
When a new reusable cell is instantiated, the widgets will invoke CreatePanel() thus setting the panel and registering itself to it, so that is not the issue. Also, I use MarkAsChangedLite() in my fix...

If it's to any help, the bug cause the same issue (visually) as this former bug I found: http://www.tasharen.com/forum/index.php?topic=3261.msg16305#msg16305

Cheers!