Ejemplo n.º 1
0
        protected void Setup()
        {
            if (transform.parent == null)
            {
                return;
            }

            MassiveZoomPickerLayoutGroup group = transform.parent.GetComponent <MassiveZoomPickerLayoutGroup>();

            if (group == null)
            {
                return;
            }

            Transform zoomItemParent = group.zoomItemParent;

            if (zoomItemParent == null)
            {
                return;
            }

            if (zoomItem != null)
            {
                foreach (Graphic graphic in zoomItem.GetComponentsInChildren <Graphic>(true))
                {
                    SetupZoomGraphic(graphic, zoomItemParent);
                }
            }
        }
Ejemplo n.º 2
0
        protected static void CopyField(MassiveZoomPickerLayoutGroup src, MassiveZoomPickerLayoutGroup dst)
        {
            if (src == null || dst == null)
            {
                return;
            }

            dst.zoomItemParent = src.zoomItemParent;
            dst.spacing        = src.spacing;
            dst.childPivot     = src.childPivot;
            dst.scrollRect     = src.scrollRect;
        }
Ejemplo n.º 3
0
        public void SetColumns(int num)
        {
            MassivePickerScrollRect[] columns = this.columns;

            if (columns == null || itemList == null || num <= 0 || columns.Length == num && itemList.Count == num || columnList == null)
            {
                return;
            }

            if (itemList.Count < num)
            {
                for (int i = itemList.Count; i < num; ++i)
                {
                    itemList.Add(new ItemListType());
                }
            }
            else if (itemList.Count > num)
            {
                itemList.RemoveRange(num, itemList.Count - num);
            }

            if (columns.Length < num)
            {
                bool zoom = columnList.GetComponentInChildren <MassiveZoomPickerLayoutGroup>() != null;

                MassivePickerScrollRect  exampleScrollRect      = columnList.GetComponentInChildren <MassivePickerScrollRect>();
                MassivePickerLayoutGroup exampleLayoutGroup     = null;
                MassivePickerLayoutGroup exampleZoomLayoutGroup = null;

                if (!zoom)
                {
                    exampleLayoutGroup = columnList.GetComponentInChildren <MassivePickerLayoutGroup>();
                }
                else
                {
                    exampleZoomLayoutGroup = columnList.GetComponentInChildren <MassiveZoomPickerLayoutGroup>();
                }

                Image exampleImage = columnList.GetComponentInChildren <Image>();

                for (int i = columns.Length; i < num; ++i)
                {
                    GameObject column = new GameObject("Column");
#if UNITY_EDITOR
                    Undo.RegisterCreatedObjectUndo(column, "Column");
#endif

                    MassivePickerScrollRect scrollRect = column.AddComponent <MassivePickerScrollRect>();

                    Image image = column.AddComponent <Image>();
                    column.AddComponent <Mask>().showMaskGraphic = true;
                    column.transform.SetParent(columnList.transform);
                    column.transform.localScale = Vector3.one;

                    GameObject content = new GameObject("Content");
                    content.transform.SetParent(column.transform);

#if UNITY_EDITOR
                    Undo.RegisterCreatedObjectUndo(column, "content");
#endif

                    if (!zoom)
                    {
                        MassivePickerLayoutGroup layoutGroup = content.AddComponent <MassivePickerLayoutGroup>();
                        CopyField(exampleLayoutGroup, layoutGroup);
                        layoutGroup.scrollRect = scrollRect;
                    }
                    else
                    {
                        MassiveZoomPickerLayoutGroup layoutGroup = content.AddComponent <MassiveZoomPickerLayoutGroup>();
                        CopyField(exampleZoomLayoutGroup, layoutGroup);
                        layoutGroup.scrollRect = scrollRect;
                    }

                    CopyField(exampleScrollRect, scrollRect);
                    scrollRect.content = (RectTransform)content.transform;

                    Util.CopyField(exampleImage, image);

                    scrollRect.deactiveItemOnAwake = IsItemChild(scrollRect);

                    itemList[i] = new ItemListType();
                }
            }
            else if (columns.Length > num)
            {
                for (int i = columns.Length - 1, j = num; i >= j; --i)
                {
                    GameObject column = columnList.GetChild(i).gameObject;
                    Util.DestroyObject(column);
                }
            }
        }