Beispiel #1
0
    void SetOpenCloseIcon()
    {
        bool isOpen = UIPopupList.current == popupList && UIPopupList.isOpen;

        RSNGUITools.SetActive(iconOpened.gameObject, isOpen);
        RSNGUITools.SetActive(iconClosed.gameObject, !isOpen);
    }
    public virtual void Init()
    {
        scrollView.Init();
        scrollView.onCyclerIndexChange += CyclerIndexChange;
        RSNGUITools.SetActive(itemPrefab, false);

        //if (WidgetsNeedRebuild()) {
        CreateWidgets();
        //}
        StartCoroutine(InitScrollPositions());
        InitButtons();

        scrollView.draggablePanel.onDrag.Add(new EventDelegate(UpdateButtons));
    }
    public void CreateWidgets()
    {
        _widgets = new UIWidget[scrollView.NbOfTransforms];

        for (int i = 0; i < scrollView.NbOfTransforms; ++i)
        {
            Transform parent = scrollView._cycledTransforms[i];

            while (parent.childCount > 0)
            {
                Transform child = parent.GetChild(0);
                child.parent = null;
                Destroy(child.gameObject);
            }

            GameObject newGO = NGUITools.AddChild(parent.gameObject, itemPrefab);
            RSNGUITools.SetActive(newGO, true);
            _widgets[i] = newGO.GetComponentInChildren <UIWidget>();
            _widgets[i].cachedTransform.localPosition = Vector3.zero;
        }
    }