예제 #1
0
        // Token: 0x060047BC RID: 18364 RVA: 0x0017AFB4 File Offset: 0x001793B4
        public override void Start()
        {
            if (this.isStartedListViewCustom)
            {
                return;
            }
            this.isStartedListViewCustom = true;
            base.Start();
            this.DestroyGameObjects = false;
            if (this.DefaultItem == null)
            {
                throw new NullReferenceException(string.Format("DefaultItem is null. Set component of type {0} to DefaultItem.", typeof(TComponent).FullName));
            }
            this.DefaultItem.gameObject.SetActive(true);
            GameObject gameObject = new GameObject("top filler");

            gameObject.transform.SetParent(this.Container);
            this.topFiller = gameObject.AddComponent <RectTransform>();
            this.topFiller.SetAsFirstSibling();
            this.topFiller.localScale = Vector3.one;
            GameObject gameObject2 = new GameObject("bottom filler");

            gameObject2.transform.SetParent(this.Container);
            this.bottomFiller            = gameObject2.AddComponent <RectTransform>();
            this.bottomFiller.localScale = Vector3.one;
            if (this.CanOptimize())
            {
                this.ScrollRect   = this.scrollRect;
                this.scrollHeight = this.scrollRect.GetComponent <RectTransform>().rect.height;
                if (this.itemHeight == 0f)
                {
                    RectTransform component     = this.DefaultItem.GetComponent <RectTransform>();
                    float         preferredSize = LayoutUtility.GetPreferredSize(component, 1);
                    this.itemHeight = ((preferredSize > 0f) ? preferredSize : component.rect.height);
                }
                this.layout = this.Container.GetComponent <EasyLayout.EasyLayout>();
                this.CalculateMaxVisibleItems();
                ResizeListener resizeListener = this.scrollRect.gameObject.AddComponent <ResizeListener>();
                resizeListener.OnResize.AddListener(new UnityAction(this.Resize));
            }
            this.customItems = this.SortItems(this.customItems);
            this.UpdateView();
            this.DefaultItem.gameObject.SetActive(false);
            this.OnSelect.AddListener(new UnityAction <int, ListViewItem>(this.OnSelectCallback));
            this.OnDeselect.AddListener(new UnityAction <int, ListViewItem>(this.OnDeselectCallback));
        }
예제 #2
0
        // Token: 0x06004741 RID: 18241 RVA: 0x00181A78 File Offset: 0x0017FE78
        public override void Start()
        {
            if (this.isStartedListView)
            {
                return;
            }
            this.isStartedListView = true;
            base.Start();
            this.DestroyGameObjects = false;
            if (this.DefaultItem == null)
            {
                throw new NullReferenceException("DefaultItem is null. Set component of type ImageAdvanced to DefaultItem.");
            }
            this.DefaultItem.gameObject.SetActive(true);
            if (this.DefaultItem.GetComponentInChildren <Text>() == null)
            {
                throw new MissingComponentException("DefaultItem don't have child with 'Text' component. Add child with 'Text' component to DefaultItem.");
            }
            GameObject gameObject = new GameObject("top filler");

            gameObject.transform.SetParent(this.Container);
            this.topFiller = gameObject.AddComponent <RectTransform>();
            this.topFiller.SetAsFirstSibling();
            this.topFiller.localScale = Vector3.one;
            GameObject gameObject2 = new GameObject("bottom filler");

            gameObject2.transform.SetParent(this.Container);
            this.bottomFiller            = gameObject2.AddComponent <RectTransform>();
            this.bottomFiller.localScale = Vector3.one;
            if (this.CanOptimize())
            {
                this.ScrollRect      = this.scrollRect;
                this.scrollHeight    = this.scrollRect.GetComponent <RectTransform>().rect.height;
                this.itemHeight      = this.DefaultItem.GetComponent <RectTransform>().rect.height;
                this.maxVisibleItems = (int)Math.Ceiling((double)(this.scrollHeight / this.itemHeight)) + 1;
                this.layout          = this.Container.GetComponent <EasyLayout.EasyLayout>();
                ResizeListener resizeListener = this.scrollRect.gameObject.AddComponent <ResizeListener>();
                resizeListener.OnResize.AddListener(new UnityAction(this.Resize));
            }
            this.UpdateItems();
            this.DefaultItem.gameObject.SetActive(false);
            this.OnSelect.AddListener(new UnityAction <int, ListViewItem>(this.OnSelectCallback));
            this.OnDeselect.AddListener(new UnityAction <int, ListViewItem>(this.OnDeselectCallback));
        }
        /// <summary>
        /// Init this instance.
        /// </summary>
        public virtual void Init()
        {
            if (isInited)
            {
                return;
            }
            isInited = true;

            var scrollRect = TileView.GetScrollRect();

            if (scrollRect != null)
            {
                ResizeListener = Utilites.GetOrAddComponent <ResizeListener>(scrollRect);

                BaseSizeDelta = (scrollRect.transform as RectTransform).sizeDelta;

                ApplyFitter();
            }
        }
        /// <summary>
        /// Sets the palette.
        /// </summary>
        /// <param name="value">Value.</param>
        protected virtual void SetPalette(Image value)
        {
            if (dragListener != null)
            {
                dragListener.OnDragEvent.RemoveListener(OnDrag);
            }

            if (clickListener != null)
            {
                clickListener.ClickEvent.RemoveListener(OnDrag);
            }

            if (resizeListener != null)
            {
                resizeListener.OnResize.RemoveListener(UpdateView);
            }

            palette = value;
            if (palette != null)
            {
                paletteRect = palette.transform as RectTransform;

                dragListener = Utilites.GetOrAddComponent <OnDragListener>(palette);
                dragListener.OnDragEvent.AddListener(OnDrag);

                clickListener = Utilites.GetOrAddComponent <ClickListener>(palette);
                clickListener.ClickEvent.AddListener(OnDrag);

                resizeListener = Utilites.GetOrAddComponent <ResizeListener>(palette);
                resizeListener.OnResize.AddListener(UpdateView);

                UpdateMaterial();
            }
            else
            {
                paletteRect = null;
            }
        }
예제 #5
0
        /// <summary>
        /// Start this instance.
        /// </summary>
        public virtual void Start()
        {
            if (isStarted)
            {
                return;
            }
            isStarted = true;

            var scrollRect = TileView.GetScrollRect();

            if (scrollRect != null)
            {
                ResizeListener = scrollRect.GetComponent <ResizeListener>();
                if (ResizeListener == null)
                {
                    ResizeListener = scrollRect.gameObject.AddComponent <ResizeListener>();
                }

                BaseSizeDelta = (scrollRect.transform as RectTransform).sizeDelta;

                ApplyFitter();
            }
        }