Support => NGUI 3 Support => Topic started by: papatriz on July 21, 2017, 07:29:19 PM
Title: How to proper move widget from ScrollView to aonther panel run-time?
Post by: papatriz on July 21, 2017, 07:29:19 PM
Hello,
I have a Scrollview with a bunch of widgets inside. Each widget actually is a button which start associated game level. I want to add visual effect when button clicked. E.g. moving and scaling its image and shadowing all other staff.
So, I have to move IconXX from ScrollView to ShadowPanel (otherwise it will be shadowed, and dont be tweened properly), and when tween it somehow. First, I did it in this way:
IconTransform.SetParent(ShadowPanel.transform);
foreach(UIWidget widget in IconTransform.GetComponentsInChildren<UIWidget>())
{
ShadowPanel.AddWidget(widget);
}
This one works almost fine for my needs - actually i see one icon staying at place and "new" instance doing tween things. But if icon transform moves outside ScrollView rect (via scaling or changing position) - it "jump" back to scroll panel: i.e. become shadowed and affected by clipping.
Of course, I tried ScrollViewPanel.RemoveWidget, but in this case NGUI stop updating widget on screen.
I tried to use panel.Refresh, panel.RebuildDrawCalls and so on, but all this things doesnt matter at all.
So my question is simple - what I do wrong? :)
Title: Re: How to proper move widget from ScrollView to aonther panel run-time?
Post by: ArenMook on July 22, 2017, 02:57:40 PM
You set its transform's parent and do NGUITools.MarkParentAsChanged on its game object to let NGUI know that you've done so.
Title: Re: How to proper move widget from ScrollView to aonther panel run-time?
Post by: papatriz on July 22, 2017, 03:41:50 PM
Thank you very much!
I looked into NGUI tools, but unfortunately miss this one.