如何从层次结构中的GameObject访问scrollRect?

时间:2015-09-18 06:25:16

标签: input scroll unity3d hierarchy

我有这个scrollPanel,我想访问Unity3D中的scrollRect,如何在层次结构顶部的StoreMenu脚本中访问它?

以下是此快照:

http://imgur.com/ZPymfJ1

2 个答案:

答案 0 :(得分:1)

基本上让它像这样工作:

            scrollpanel = GameObject.Find("ScrollPanel");
            scrollRect = scrollpanel.GetComponent<ScrollRect>();
            scrollRect.GetComponent<ScrollRect>();

答案 1 :(得分:0)

您也可以使用方法GetComponentInChildren()。它将遍历层次结构并找到您想要的组件或其子组件。