I've created a special table that reuses cell-objects (much like in the Android or iOS api), which basically instantiates as many cell-objects as needed for all cells currently within screen, and then reuses cells going out of screen for cells going in on screen (simplified).
So without getting to complicated with details, I've found after a whole day trying that it comes down to the following to recreate the bug(?):
- Instantiate a prefab (GameObject of scale (1,1,1) that holds multiple widgets) using AddChild or any likewise method for that matter
- Reparent the instantiated gameObject to empty (scale (1,1,1)) gameObjectA under your panel (done automatically if you use AddChild ofc.)
- Change the sprite of any UISprite-widget parented to the instantiated gameObject
- Reparent the instantiated gameObject again to empty (scale (1,1,1)) gameObjectB under the same panel
Doing this will work fine until you try to move the instantiated objects
PARENT which in this case is
gameObjectB. The instantiated object will move (gizmos showing how widgets move along), but the actual graphic will stay in the same place... If I (in the editor) reparent the instantiated object to any other gameObject (for example
gameObjectA) it works fine, but if a place it back to
gameObjectB again it's still not working.
To make it work again, I'll have to disable and enable the responsible UIPanel. As a sidenote, it WILL WORK if you skip the first parenting to
gameObjectA (step 2).
The above order is required for the generic nature of the table, since reusable objects will be instantiated, and then reparented around depending on if they are visible or not. Inbetween this reparanting the client (table-handler-script) will be requested to setup a specific cell about to be visible, which is where the actual sprite-change occures. So basically, a short "well then don't do it this way"-answer won't really help me (and I think this bug-or-whatever should not be ignored).
See attached image for this epic randomness!As you can see, all the white bounds are the widgets in the CORRECT position, however the actual graphic is not redrawn... I've tried to understand all that happens in UIPanel, but writing this topic seemed easier!
EDIT: For all interested, the bug was found and will be available in the next update. Here is the fix until then:Michael Lyashenko:
Thank you for the simple repro case! I found the issue. 2.3.5 will have the fix. You can fix it locally by opening up UIPanel and replacing AddTransform function with this: UINode AddTransform (Transform t)
{
UINode node = null;
UINode retVal = null;
// Add transforms all the way up to the panel
while (t != null && t != cachedTransform)
{
#if UNITY_FLASH
if (mChildren.TryGetValue(t, out node))
{
if (retVal == null)
retVal = node;
}
#else
if (mChildren.Contains(t))
{
if (retVal == null)
retVal = (UINode)mChildren[t];
}
#endif
else
{
// The node is not yet managed -- add it to the list
if (retVal == null) retVal = node;
mChildren.Add(t, node);
}
t = t.parent;
}
return retVal;
}