سؤال

Not sure this is the best forum for Unity3d/NGUI questions but give it a try...

I am trying to move a gameobject from a scrollable panel to a normal panel by reparenting it.

firstGameObject.transform.parent = secondGameObject.transform;

firstGameObject is initially child of a clipped scrollable panel. The transform seems to move just fine in the hierarchy and no longer becoming scrollable. But it is still clipped like it was a child of the clipped panel.

Any ideas?

Edit: Someone at NGUI's forum suggested calling Refresh() on both uipanels, but it had no effect. http://www.tasharen.com/forum/index.php?topic=1941.0

هل كانت مفيدة؟

المحلول

Finally got it working. The correct way was to call CheckParent() on each widget in the old panel after reparenting.

UIPanel smallPanel = NGUITools.FindInParents<UIPanel>(firstGameObject);
List<UIWidget> list = new List<UIWidget>(smallPanel.widgets.buffer);

foreach (UIWidget widget in list)
{
    if (widget != null)
    {
        widget.CheckParent();
    }
}

نصائح أخرى

Function CheckParent() is obsolete. Now you can use ParentHasChanged() on reparented UIWidget.

It depends on what scroll bar are you using. Setting new parent to prefab you only setting new local coordinate system to it. You saing that objects in this scroll bar are clipping. So, there must be an array or list or something like that, storing your prefab and making some actions on your prefab. Or, there is some kind of mask, that hides ALL objects in specific area (I think that is your case). In that case you should move your prefab out of mask's area. If you don't need to change screen position, change only Z coordanate, so prefab will becom closer to camera, and out of mask area.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top