Example #1
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListViewCustom)
            {
                return;
            }
            isStartedListViewCustom = true;

            base.Start();

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException(String.Format("DefaultItem is null. Set component of type {0} to DefaultItem.", typeof(TComponent).FullName));
            }
            DefaultItem.gameObject.SetActive(true);

            var topFillerObj = new GameObject("top filler");

            topFillerObj.transform.SetParent(Container);
            topFiller = topFillerObj.AddComponent <RectTransform>();
            topFiller.SetAsFirstSibling();
            topFiller.localScale = Vector3.one;

            var bottomFillerObj = new GameObject("bottom filler");

            bottomFillerObj.transform.SetParent(Container);
            bottomFiller            = bottomFillerObj.AddComponent <RectTransform>();
            bottomFiller.localScale = Vector3.one;

            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                scrollHeight = scrollRect.GetComponent <RectTransform>().rect.height;
                if (itemHeight == 0)
                {
                    var rect             = DefaultItem.GetComponent <RectTransform>();
                    var preffered_height = LayoutUtility.GetPreferredSize(rect, 1);
                    itemHeight = (preffered_height <= 0) ? rect.rect.height : preffered_height;
                }
                layout = Container.GetComponent <EasyLayout.EasyLayout>();
                CalculateMaxVisibleItems();

                var r = scrollRect.gameObject.AddComponent <ResizeListener>();
                r.OnResize.AddListener(Resize);
            }

            customItems = SortItems(customItems);
            UpdateView();

            DefaultItem.gameObject.SetActive(false);

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
Example #2
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListView)
            {
                return;
            }
            isStartedListView = true;

            base.Start();
            base.Items = new List <ListViewItem>();

            SelectedItemsCache = SelectedIndicies.Convert <int, string>(GetDataItem);

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException("DefaultItem is null. Set component of type ImageAdvanced to DefaultItem.");
            }
            DefaultItem.gameObject.SetActive(true);
            if (DefaultItem.GetComponentInChildren <Text>() == null)
            {
                throw new MissingComponentException("DefaultItem don't have child with 'Text' component. Add child with 'Text' component to DefaultItem.");
            }

            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                var scrollRectTransform = scrollRect.transform as RectTransform;
                scrollHeight = scrollRectTransform.rect.height;
                scrollWidth  = scrollRectTransform.rect.width;

                layout = Container.GetComponent <LayoutGroup>();
                if (layout is EasyLayout.EasyLayout)
                {
                    LayoutBridge = new EasyLayoutBridge(layout as EasyLayout.EasyLayout, DefaultItem.transform as RectTransform);
                    LayoutBridge.IsHorizontal = IsHorizontal();
                }
                else if (layout is HorizontalOrVerticalLayoutGroup)
                {
                    LayoutBridge = new StandardLayoutBridge(layout as HorizontalOrVerticalLayoutGroup, DefaultItem.transform as RectTransform);
                }

                CalculateItemSize();
                CalculateMaxVisibleItems();
            }

            DefaultItem.gameObject.SetActive(false);

            UpdateItems();

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
Example #3
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListView)
            {
                return;
            }
            isStartedListView = true;

            base.Start();

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException("DefaultItem is null. Set component of type ImageAdvanced to DefaultItem.");
            }
            DefaultItem.gameObject.SetActive(true);
            if (DefaultItem.GetComponentInChildren <Text>() == null)
            {
                throw new MissingComponentException("DefaultItem don't have child with 'Text' component. Add child with 'Text' component to DefaultItem.");
            }

            var topFillerObj = new GameObject("top filler");

            topFillerObj.transform.SetParent(Container);
            topFiller = topFillerObj.AddComponent <RectTransform>();
            topFiller.SetAsFirstSibling();
            topFiller.localScale = Vector3.one;

            var bottomFillerObj = new GameObject("bottom filler");

            bottomFillerObj.transform.SetParent(Container);
            bottomFiller            = bottomFillerObj.AddComponent <RectTransform>();
            bottomFiller.localScale = Vector3.one;

            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                scrollHeight    = scrollRect.GetComponent <RectTransform>().rect.height;
                itemHeight      = DefaultItem.GetComponent <RectTransform>().rect.height;
                maxVisibleItems = (int)Math.Ceiling(scrollHeight / itemHeight) + 1;
                layout          = Container.GetComponent <EasyLayout.EasyLayout>();

                var r = scrollRect.gameObject.AddComponent <ResizeListener>();
                r.OnResize.AddListener(Resize);
            }

            UpdateItems();

            DefaultItem.gameObject.SetActive(false);

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
Example #4
0
    private void Awake()
    {
        OnSelect.AddListener(SelectDown);
        OnSelectUp.AddListener(SelectUp);
        OnDeselect.AddListener(Deselect);

        originalColor = GetComponent <SpriteRenderer>().color;

        attrs.isNeighbour = false;
        attrs.isSelected  = false;
    }
Example #5
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListViewCustom)
            {
                return;
            }

            base.Start();
            base.Items = new List <ListViewItem>();

            SelectedItemsCache = SelectedItems;

            SetItemIndicies = false;

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException(String.Format("DefaultItem is null. Set component of type {0} to DefaultItem.", typeof(TComponent).FullName));
            }
            DefaultItem.gameObject.SetActive(true);

            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                var scroll_rect_transform = scrollRect.transform as RectTransform;
                scrollHeight = scroll_rect_transform.rect.height;
                scrollWidth  = scroll_rect_transform.rect.width;

                CalculateItemSize();

                layout          = Container.GetComponent <EasyLayout.EasyLayout>();
                layout.Stacking = (IsHorizontal()) ? EasyLayout.Stackings.Vertical : EasyLayout.Stackings.Horizontal;

                CalculateMaxVisibleItems();

                var r = scrollRect.gameObject.AddComponent <ResizeListener>();
                r.OnResize.AddListener(SetNeedResize);
            }

            DefaultItem.gameObject.SetActive(false);

            Direction = direction;

            UpdateItems();

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);

            isStartedListViewCustom = true;
        }
Example #6
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListViewGameObjects)
            {
                return;
            }
            isStartedListViewGameObjects = true;

            base.Start();

            DestroyGameObjects = true;

            UpdateItems();

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
Example #7
0
        public SpriteButton(int index, Button buttonElement)
        {
            Element = buttonElement;
            Index   = index;

            OnActivate.AddListener(delegate
            {
                Element.onClick.Invoke();
            });

            OnSelect.AddListener(delegate
            {
                Element.OnPointerEnter(null);
            });

            OnUnselect.AddListener(delegate
            {
                Element.OnPointerExit(null);
            });
        }
Example #8
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedTreeViewCustom)
            {
                return;
            }
            isStartedTreeViewCustom = true;

            setContentSizeFitter = false;

            base.Start();

            Refresh();

            OnSelect.AddListener(OnSelectNode);
            OnDeselect.AddListener(OnDeselectNode);
            KeepSelection = false;

            DataSource = NodesList;
        }
Example #9
0
        void Start()
        {
            OnInitialize.Invoke();

            header.OnToggleValueChanged(v =>
            {
                if (v)
                {
                    Open();
                }
                else
                {
                    Close();
                }
            });

            header.OnClickKillButton(() => Kill());

            OnSelect.AddListener(() => Transform.SetAsLastSibling());
            variableSizePanel.OnSizeChange.AddListener(sizeDelta => scrollRect.SetSizeDelta(y: sizeDelta.y - IgniteGUISettings.ElementHeight));
            backgroundImage.color = IgniteGUISettings.WindowContentColor;
            dragAreaImage.color   = IgniteGUISettings.WindowDragAreaColor;
        }
Example #10
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListView)
            {
                return;
            }
            isStartedListView = true;

            base.Start();
            base.Items = new List <ListViewItem>();

            SelectedItemsCache = SelectedIndicies.ConvertAll <string>(GetDataItem);

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException("DefaultItem is null. Set component of type ImageAdvanced to DefaultItem.");
            }
            DefaultItem.gameObject.SetActive(true);
            if (DefaultItem.GetComponentInChildren <Text>() == null)
            {
                throw new MissingComponentException("DefaultItem don't have child with 'Text' component. Add child with 'Text' component to DefaultItem.");
            }

            var topFillerObj = new GameObject("top filler");

            topFillerObj.transform.SetParent(Container);
            topFiller = topFillerObj.AddComponent <RectTransform>();
            topFiller.SetAsFirstSibling();
            topFiller.localScale = Vector3.one;

            var bottomFillerObj = new GameObject("bottom filler");

            bottomFillerObj.transform.SetParent(Container);
            bottomFiller            = bottomFillerObj.AddComponent <RectTransform>();
            bottomFiller.localScale = Vector3.one;

            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                var scrollRectTransform = scrollRect.transform as RectTransform;
                scrollHeight = scrollRectTransform.rect.height;
                scrollWidth  = scrollRectTransform.rect.width;

                var itemRectTransform = DefaultItem.transform as RectTransform;
                itemHeight = itemRectTransform.rect.height;
                itemWidth  = itemRectTransform.rect.width;

                layout = Container.GetComponent <EasyLayout.EasyLayout>();

                CalculateMaxVisibleItems();
            }

            DefaultItem.gameObject.SetActive(false);

            UpdateItems();

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
Example #11
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public override void Start()
        {
            if (isStartedListViewCustom)
            {
                return;
            }
            isStartedListViewCustom = true;

            base.Start();
            base.Items = new List <ListViewItem>();

            SelectedItemsCache = SelectedItems;

            SetItemIndicies = false;

            DestroyGameObjects = false;

            if (DefaultItem == null)
            {
                throw new NullReferenceException(String.Format("DefaultItem is null. Set component of type {0} to DefaultItem.", typeof(TComponent).FullName));
            }
            DefaultItem.gameObject.SetActive(true);


            if (CanOptimize())
            {
                ScrollRect = scrollRect;

                var scroll_rect_transform = scrollRect.transform as RectTransform;
                scrollHeight = scroll_rect_transform.rect.height;
                scrollWidth  = scroll_rect_transform.rect.width;

                layout = Container.GetComponent <LayoutGroup>();

                if (layout is EasyLayout.EasyLayout)
                {
                    LayoutBridge = new EasyLayoutBridge(layout as EasyLayout.EasyLayout, DefaultItem.transform as RectTransform, setContentSizeFitter);
                    LayoutBridge.IsHorizontal = IsHorizontal();
                }
                else if (layout is HorizontalOrVerticalLayoutGroup)
                {
                    LayoutBridge = new StandardLayoutBridge(layout as HorizontalOrVerticalLayoutGroup, DefaultItem.transform as RectTransform, setContentSizeFitter);
                }

                CalculateItemSize();
                CalculateMaxVisibleItems();

                var resizeListener = scrollRect.GetComponent <ResizeListener>();
                if (resizeListener == null)
                {
                    resizeListener = scrollRect.gameObject.AddComponent <ResizeListener>();
                }
                resizeListener.OnResize.AddListener(SetNeedResize);
            }

            DefaultItem.gameObject.SetActive(false);

            SetDirection(direction, false);

            UpdateItems();

            OnSelect.AddListener(OnSelectCallback);
            OnDeselect.AddListener(OnDeselectCallback);
        }
 public override void Start()
 {
     editBox = transform.parent.GetComponentInChildren <ConditionalEditBox>();
     base.Start();
     OnSelect.AddListener(NewSelect);
 }