Unity3d(NGUI)中面板之间重新预留的预制件(Reparenting prefabs between to panels in Unity3d (NGUI))

编程入门 行业动态 更新时间:2024-10-25 14:27:40
Unity3d(NGUI)中面板之间重新预留的预制件(Reparenting prefabs between to panels in Unity3d (NGUI))

不确定这是Unity3d / NGUI问题的最佳论坛,但试一试......

我试图通过重新创建将游戏对象从可滚动面板移动到普通面板。

firstGameObject.transform.parent = secondGameObject.transform;

firstGameObject最初是剪切的可滚动面板的子代。 转换似乎在层次结构中移动得很好,不再可以滚动。 但它仍然被裁剪成像裁剪面板的孩子一样。

有任何想法吗?

编辑:NGUI论坛的某人建议在两个uipanel上调用Refresh(),但它没有效果。 http://www.tasharen.com/forum/index.php?topic=1941.0

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

最满意答案

终于搞定了。 正确的方法是在重新显示后在旧面板中的每个窗口小部件上调用CheckParent()。

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(); } }

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(); } }

更多推荐

本文发布于:2023-07-29 05:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1312637.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:预制件   面板   NGUI   Unity3d   prefabs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!